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.

Newcomers DBPro Corner / Bitmap Merge?

Author
Message
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 14th Jan 2013 19:55
Hi
I was wondering if there is a way to merge bitmaps.
For example if I create a circle, box and 2 line on 3 separate bitmaps
can I then merge them to bitmap 0(ie screen).
so that all 3 items show up circle,line and box.




I used copy bitmap in the example program which I know wont work.
If this is not possible is there a way round this?

Thanks in advance.

Scotty
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jan 2013 23:19
Hi.

You have the right idea, but the problem is that you're not just copying the shapes you drew, you're copying the entire bitmap (including the black area), which will of course paste over everything else on the bitmap beneath.

Here is a horribly inefficient modification to your above code:



What do you need this for eventually? This will help us make a much more efficient example for you.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 15th Jan 2013 12:34
Hi

I was looking at using separate bitmaps to store the various layers of a level editor. Therefore the user could turn off layers for editing and the plan was to merge layers in this correct order as it will be displayed on screen.

This would then create a big bitmap of the current level which I can then either separate into tiles or use the pixel positions stored to get the game engine to place the items in the correct position.

I'm sure there is probably a better way to do this.

Many thanks

Scotty
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Jan 2013 17:52
Hmm, does your level editor have to output images? Or would a tile based level editor work for you as well, like this one?

If you're going for the image solution, the above code will be enough. It is slow, but you'll only be merging them once (when you save) and therefore don't require any real-time merging.

If you want to speed up your image merging routine, I suggest downloading the plugin Image Kit. It has some high speed image operations you will find useful, and you won't need those clunky bitmaps anymore.

Further, you should also look into image manipulation using memblocks so you can get rid of using bitmaps completely.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 15th Jan 2013 23:42
Hi

Not really like the one you linked - I do like the look of that one!!

I think I will look at the image kit to see if that is a better way about it.

What I am trying to do is to output a bitmap and/or output the image coordinates for another program to use.

The idea is to have a selection of different sized sprites which you can then place onto the map.

Thanks

Scotty
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Jan 2013 01:02
I would suggest Matrix1 Util library. It has the "draw to image" command which can make ImageKit much better to use.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Jan 2013 13:42
Hi there.
Time ago I made a piece of code that works perfect. Now I'm out and have not the code here...what I did, load two images 100x100pixels, and paste image 1 0,0...and image 2 in 100,0...then something like:

For i=1 to 100
For a=1to 100
Col=rgbr(point i,a)
Cal=rgbr(point i+100,a ...to get colour pixels of second image
dot 300,0 rgbr( col+cal)
Next a
next i

It was just that...and then I could get the merged image in:
Get image 3,0,0,300,100,1

Probably I made some mistakes in this example here...sorry,I'm with my smartphone.
The other way I got good result, was as easy as making a plane ...texturing with first image, and setting lightmapping on the object the second image...lastly geting the merged image...I hope this ideas can help


Cheers.

I'm not a grumpy grandpa
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 17th Jan 2013 18:29
Hi

Thanks for all the suggestions, got plenty of options to try now.

Scotty

Login to post a reply

Server time is: 2024-04-26 18:06:48
Your offset time is: 2024-04-26 18:06:48