2017년 7월 10일 월요일

How many MB does a single sprite take up


How many MB does a single sprite take up?  I've heard tell that there's a limit of 100 MB for each App Inventor app.

--
If you use a sprite (on the canvas) , you have to upload one and you can see how big it is. Normally you have to use a paint or photo program to create it and then you can change the size. 

this sprite is 163*309 pixels and the file size is 11kb (kilobyte) you can use 91 pcs and you have 1MB.


--
Thanks! After an app is uploaded, how many images from the device (gotten via filepath) can be shown at once?


--
In the documentation about using images, the last paragraph of "Out of memory errors" says :App Inventor lets you get  images (for example, from the Web) and import these into your app as Media.  When you use the images, and App Inventor will rescale them to fit the designated screen area in your app.    Sometimes the image to be displayed will be larger than the designed phone area.   Even so, the large image needs to be held in memory in order for rescaling to occur, even if the result of the rescaling will be a small image."
I had no idea images from the web would take up space.  So that means I couldn't bring in and show a lot of large size (or a whole lot of smaller size) images from the web?

Do images gotten via filepath from the device take up space in the app, too?  If so, I'm sunk.  I'm creating an app that will be displaying thousands of images from the web and/or from the device.

-- 
and import these into your app as Media

which means the documentation is talking about uploading files to the assets inside the app and not about displaying images directly from the web

if you want to display images directly from the web, then these should be not too large to reduce loading time...

it probably would be a good idea to do some example projects to test several functionality before working on the big project...

I think, the problem is to display several images at the same time... if you display them one by one or only a few at the same time, then you should not have memory problems...


--
 Nice flung project.  I'm guessing canvas's flung handler won't work when the screen is scrollable, right?

I will do some experimenting, as you suggest.  Would there be a problem displaying a bunch of images from the device (via filepath) at the same time?

-- 
You will run into problems if you use many images or few images but very large images. Each Android process is allowed only so much memory (on earlier phones, it was 8 MB, nowadays 128 MB is typical, but it depends on the phone and Android version). The Sprite image above, while only being 11 KB on disk, will be roughly 200 KB in memory. This is because for the image to be drawn, it must be uncompressed from the JPG format and represented as a WxH grid of 4-byte pixels (alpha, red, green, blue) that is copied to the screen. To get a sense of how big each picture is to be held in memory, multiply the width and height together and then multiply that by 4. The App Inventor framework will attempt to scale images that are at least 2x the width and height of the screen automatically to reduce the memory load, but that won't protect you indefinitely from OutOfMemoryErrors. So ultimately the number of images you will be allowed to draw at one time will be a function of how big those images are uncompressed and the memory allowed per process on the user's phone.

-- 
Okay.  Wow.  Thank you so much.  Makes me wonder how all those image-filled video game apps are done.

So if I had a 35 by 35 px image, that would be 1,225... KB?  And if I had 12 of those that would be 14,700 KB.  Would that blow the average phone?

If I had 60 images 35 by 35, that would be 61,250 KB.  On a tablet would that be a whole lot?  I have no idea.

The user cropping the images to the size they'll be displayed should help, I think?

-Clueless

-- 
You're off on the math:

35 x 35 = 1225 pixels x 4 bytes/pixel = 4900 bytes (not KB!) = ~5 KB
If you have 60 of those: 4900 x 60 = 294000 bytes (not KB!) = ~288 KB

Cropping or resizing will reduce the amount of memory used because it makes the image smaller. Simply compressing by switching to JPG or PNG will not help runtime size (although it does help keep you below the 10 MB App Inventor limit).

-- 
That's not so bad after all (maybe).

-- 
(added to new Limits section of FAQ FAQ for Limits )

-- 

댓글 없음:

댓글 쓰기