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.

DarkBASIC Professional Discussion / I need to create a large image using memblock?

Author
Message
dman
21
Years of Service
User Offline
Joined: 21st Feb 2005
Location:
Posted: 15th May 2010 20:38 Edited at: 15th May 2010 22:48
How can I create a large image using the "copy memblock"

I used "get image" and "make memblock from image" then I used "copy memblock" then "make image from memblock" ??

I increase the position in "copy memblock" to capture each frame.

here is the code I used, nothing is showing when I pasted the image. please let me know whats wrong with it. thanks.


Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th May 2010 23:04 Edited at: 16th May 2010 16:09
A memblock is just a chunk of memory you can use.
make memblock from image turns an image into readable data you can edit. This data is written in a certain structure:

4 bytes = 1 DWORD containing the image width
4 bytes = 1 DWORD containing the image height
4 bytes = 1 DWORD containing the image depth [edit]Correction: see Diggsey's post below
and then
width * height * (depth in bytes) bytes for the actual data of the image.
EG. Usually the image depth is 32 (4 bytes), then the actual data would be
- Blue (1 byte)
- Green (1 byte)
- Red (1 byte)
- Alpha (1 byte)
for each point on your image.

You first have to understand this completely before you can effectively use memblocks.

If you understand this, then you should also realize that "copy memblock" won't allow you to simply "copy" image data from one memblock to another, and achieve the effect of "pasting" an image on another.

I would recommend this plug-in of mine: Image Kit.
You can use copy image ToImgNr, FromImgNr, Left, Top, Right, Bottom to copy a chunk of an image, or use get image like you're doing now, and then use paste image on image ImgNr, x, y to paste on another image.
A new image is created using the command create image ImgNr, Width, Height or create target image ImgNr, Width, Height. I thought it would make things a little easier.

Of course, if you want to learn about using image memblocks, then I advise you to use the search button.

Cheers!
Sven B

dman
21
Years of Service
User Offline
Joined: 21st Feb 2005
Location:
Posted: 15th May 2010 23:32
Hey, This looks very interesting. can not wait to use it, Is there a example you can give me using these commands?

I want to use copy image and paste image.

copy sections of images and then make one long image.


I appreciate the help thanks very much.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th May 2010 13:56
Sven's got it covered, but I'd just like to post a little code example, this takes an image and crops it left and right, but it takes the image as a memblock then makes a new memblock with just the cropped data. I'm using it for cheap variable width fonts - so I can use image width when incrementing the X position when pasting letters. I think it's a good idea to know memblock images, even if you do use the excellent ImageKit.




Health, Ammo, and bacon and eggs!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th May 2010 14:19 Edited at: 16th May 2010 14:21
The depth value is not in bits, it is a number identifying the format. If you view the help files for make memblock from image, it shows the list of identifiers. Although a value of '32' gives a 32 bit image with red, green, blue and alpha channels, the channels are in an unusual order and it is not supported by many cards. The one you should use is also 32bit but the channels are in a different order and I think it's number 21.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th May 2010 16:07
Thanks Diggsey, then I learned something new too

dman
21
Years of Service
User Offline
Joined: 21st Feb 2005
Location:
Posted: 16th May 2010 18:59 Edited at: 16th May 2010 19:03
Hi Sven B, I'm trying to use your plugin. I'm having a little problem with "paste image on image" when I "paste image" to the screen I get over lap images and unable to scroll left to the whole image. I tried to resize also and it wont do the whole image, maybe the image is too large. Please help.

here is the code.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th May 2010 22:05
After testing something similar it is true that paste image on image behaves strangely. But it only does this with large images. 20 * 640 seems to be the limit.

The strange thing is that even when using image dot, that dot is stretched. While the only thing I'm doing is changing only one DWORD (=1 pixel color). It means that the problem might lie in Direct3D.
Using a target image doesn't change anything. The "stretching" is still there. Even more reason that the problem might be how Direct3D handles its images.

I would avoid using such large images. It seems that 640 * 20 is the limit, so I'd use that one for a maximum. I've noticed it doesn't give any problems if you add a bit to the height (create image 2, 640*10, 200*3 or something), but make sure you don't run out of memory.

Cheers!
Sven B

dman
21
Years of Service
User Offline
Joined: 21st Feb 2005
Location:
Posted: 16th May 2010 22:19
ok, maybe I should use memblock for long images 640*30.

since its using memory and you can use the amount of memory thats available.

Is this not true?
dman
21
Years of Service
User Offline
Joined: 21st Feb 2005
Location:
Posted: 17th May 2010 22:21
Hi Van B, I find your code for cropping images interesting.

maybe you can help me with memblock. I'm trying to use it to get a large image from several images. I know its possible to do, just how.

I tried to make sense of the code you provided on top, but I'm lost.
I have a little idea what is going on. Please help. Thanks

Login to post a reply

Server time is: 2026-07-25 23:12:14
Your offset time is: 2026-07-25 23:12:14