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 / Create Image from Memblock crash the app

Author
Message
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 8th Mar 2019 06:27 Edited at: 8th Mar 2019 06:34
The following crash:


I try starting at byte 1 instead of 0, but it crash as well.
puzzler2018
User Banned
Posted: 8th Mar 2019 07:18
Try



Do you want all red cause that will show red with no alpha

Tier 1 Developer
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 8th Mar 2019 07:50
It seems I forget to count the byte! LOL!
Anyway, the image does indeed show up as a white image for me.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 8th Mar 2019 09:58
Puzzler, he's setting every single byte to 255, soit will be opaque white.
puzzler2018
User Banned
Posted: 8th Mar 2019 12:57
Yeah sorry Santman - was in a rush ealier



Tier 1 Developer
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Mar 2019 13:35 Edited at: 8th Mar 2019 13:38
Your Step value should be 4 rather than the default 1 if your setting the colours separately...otherwise your actually calling SetMemblockByte() 4 times for every x value.

Also...dont forget to delete the memblock if your finished with it.

And the memblock size just needs to be 1920 x 1080 x 4 +12 = 8294412 Not sure why the extra byte was needed above?


Also...id just use:

im = CreateImageColor(255,255,255,255)
ResizeImage(im,1920,1080)

Much quicker to code and easier too if all you want is a 1920,1080 blank image...then create a memblock from that image if you want to manipulate values directly

memblk = CreateMemblockFromImage(im)

Saves iterating through 8 million byte setting calls
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 11th Mar 2019 20:59
It seems to crash without the extra byte?
Not really sure if it is a bug...?

In step 4 for for loop, it seems to also complain about there not being 4 byte from the last 4 so it could not put in a integer.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 11th Mar 2019 21:07 Edited at: 11th Mar 2019 21:19
You only need 4 * 1920* 1080 + 12 bytes for an image 1920 x 1080

That gives a memblock size of 8294412

The problem was your for x =12 to 8294412 should have been x=12 to 8294411

Here is code that creates the image without using the extra byte that will never be used or seen



Unlike arrays...memblocks start at an offset of 0 and the highest byte in the memblock is the size of the memblock-1


If you want to set all 4 colours inside of the loop then make the step 4 and loop until you are 4 less than the memblock size...like this




In any case...if you want a memblock with a solid colour in it, the fastest and easiest code is simply to make a single pixel image (CreateImageColor()) and resize it (ResizeImage()) then create the memblock from that. Huge loops in interpreted basic are not really very fast really.

Login to post a reply

Server time is: 2024-11-23 02:49:40
Your offset time is: 2024-11-23 02:49:40