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.

Dark GDK / Memblock from Image issue

Author
Message
Krisacz
15
Years of Service
User Offline
Joined: 3rd Mar 2009
Location: UK, Manchester
Posted: 4th Mar 2009 13:04
Hi Guys/Girls (if there any here!
I trying to "paste" one small picture into another( much bigger one) using MemblockFromImage. Problem is that "pasted" image is much different that original one (see pastedimage.bmp in attachment). Could you tell me what I'm doing wrong? I don't want to simply sprite it somewhere on the screen, I want to modify existing background image by changing some of it's pixels equal to smaller picture pixels. I hope you know what I mean. Basically I will be using it for example making stamps/marks of blood/enemy bodies on background etc. If I will use sprite for that it's will use a lot of memory so I thing that's the best solution. I will be very glad if some will help me with it, I spent loads of time trying to find where problem is and now I'm really desperate. That's code what I using at the moment, and in attachment there are 2 pictures witch I'm using (background and square). Third picture is an image of "pasted" square into background. Thanks! :

Attachments

Login to view attachments
Scottie Dog
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 5th Mar 2009 12:16
GetImage is stretching your image. You need to force it into the size you require. Change your startup code to the following:

dbLoadImage("background.jpg",1); //simple bacground image 1024X1024
dbCreateBitmap(2,20,20);
dbLoadBitmap("square.bmp",2); //simple square image, 20x20, red frame, white inside
dbMakeMemblockFromBitmap(2,2); //making memblock from square bitmap
dbSetCurrentBitmap(0);
dbSprite(1,0,0,1); //pasting background
Scottie Dog
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 5th Mar 2009 12:20
Oh and you only need to make the background memblock in your while loop. The 20x20memblock does need to be made everytime.

dbMakeMemblockFromImage(1,1); //making memblock from background bitmap
//dbMakeMemblockFromImage(2,2); //making memblock from square bitmap
Scottie Dog
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 5th Mar 2009 12:27
For Completness Heres my version of the code


Krisacz
15
Years of Service
User Offline
Joined: 3rd Mar 2009
Location: UK, Manchester
Posted: 6th Mar 2009 09:48
Thank you so much! It's working now.

Why using dbMakeMemblockFromImage is stretching image? That's a little bit weird isn't?

Login to post a reply

Server time is: 2024-09-30 19:13:16
Your offset time is: 2024-09-30 19:13:16