Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Square Image

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Jan 2015 21:42
Hi.

I have a question, if I use Square Image (e.g: 512 x 512) but there is empty space in it, This space can be calculated? mean usage memory?

Thanks.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jan 2015 10:19
Every pixel is 4 bytes of memory (red,green,blue,alpha). Once an image is loaded it is uncompressed, so jpg compression is irrelevant once loaded.

Quidquid latine dictum sit, altum sonatur
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jan 2015 10:21
Please give us a little more detail to help put the question into context. Are you talking about an empty square or rectangular space? If so, then calculate it using the width * height * 4 (for the RGBA per pixel). If you have an irregular shaped space, then you are talking about something like a flood-fill algorithm to work out the total number of pixels to fill the space, or perhaps you need to calculate the bounding box size required to enclose the space. What do you need this for?

Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Jan 2015 16:09 Edited at: 8th Jan 2015 13:34


Call this function, it will return the amount of memory being used by transparent pixels.
I've no idea why you would need to know that though.

[Code fixed after testing]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jan 2015 16:21
I think it should be 15, not 16...

for b = 15 to GetMemblockSize( mb ) step 4

0 - 3 = width
4 - 7 = height
8 - 11 = depth
12 = blue
13 = green
14 = red
15 = alpha
etc...

Quidquid latine dictum sit, altum sonatur
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Jan 2015 16:21
Image space is never empty. Blank, maybe. In that case, eyes are a good tool to use.

Onwards and sometimes upwards
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Jan 2015 17:43
Quote: "for b = 15 to GetMemblockSize( mb ) step 4"


Ah yes, of course. I forgot it was zero based. You might have to reduce the end limit of the loop too depending on whether GetMemblockSize() returns the actual number of bytes or the zero based number.

Login to post a reply

Server time is: 2024-05-19 14:56:31
Your offset time is: 2024-05-19 14:56:31