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 / loading two bitmap at the same time

Author
Message
SpoonAndFork
14
Years of Service
User Offline
Joined: 9th Oct 2011
Location:
Posted: 17th Oct 2011 23:27
hi good day. just wondering is it possible to load two bitmaps at the same time and get image from that two bitmap at the same time to display in the screen? or maybe is it possible to get two images from a single bitmap and display them at the same time

thanks!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Oct 2011 00:43
What are you up to? why don't you load both images and display them at the same time?

Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Oct 2011 01:49
Bitmaps can be resized if that's what you mean. Yes you can load multiple bitmaps/images. Stretching them you would need to experiment with the "COPY BITMAP" commands unless you're using a plugin for DBP. Do what you need with the BITMAPs and then convert to IMAGEs then paste them onto the screen. The help files should give you 99% of the info on how to use the commands...

If you get stuck then just provide a snippet of your code and anyone can point out where your going wrong.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 18th Oct 2011 05:47
you can get as many images as you want from a single bitmap.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Oct 2011 07:50
Yes, you can load 2 bitmaps at the same time, but you'll need to use the command set current bitmap to switch between them when grabbing images. You can grab as many images as you want from bitmaps, and you can of course display as many images as you want (as long as you don't have more than 65536 images).

TheComet

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Oct 2011 11:19
But depending on the size of the bitmaps, it would be very very slow. You'd be better off loading the two images as, well images, putting them on a sprite, and changing their UV coordinates to show only the parts of the images you want to see.

Don't forget about the excellent imagekit plugin as well. It allows for faster and cooler manipulation of off screen images, much the way bitmaps work, but way way way more efficient.

My signature is NOT a moderator plaything! Stop changing it!
SpoonAndFork
14
Years of Service
User Offline
Joined: 9th Oct 2011
Location:
Posted: 19th Oct 2011 11:05
thanks for the replies i have decided to use more than 1 bitmap. but now the problem is i dont know how to switch them like TheComet said. i have attached two bitmaps the char.png is for the movements of the character and the attack.png is for the attacking effects. i want to display (when a key is pressed) a movement of the character(char.png) while displaying the effects(attack.png).

thanks for the help and i apologize for my poor explanation skills.

KANRA || CINDY
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2011 13:48
Those two images look exactly the same to me. Could you check your files and re-post the RAR file if necessary?

Anyway, it looks like you need to use the second form of the copy bitmap command:

Quote: "COPY BITMAP
This command will copy the contents of one bitmap into another bitmap providing the destination bitmap is not smaller than the first.

Syntax

COPY BITMAP From Bitmap,To Bitmap

COPY BITMAP From Bitmap,Left,Top,Right,Bottom,To Bitmap,Left,Top,Right,Bottom

Parameters
"


You'll need to work out the pixel coordinates of the corners of each sub-image. I'd store them in a UDT array.
SpoonAndFork
14
Years of Service
User Offline
Joined: 9th Oct 2011
Location:
Posted: 7th Nov 2011 12:50
umm sorry for the very late reply. there 2 are different images.

i don't know how to switch between bitmaps and displaying them at the same time so that there are two images and be manipulated by keyboard.

here's my example scenario. i have image1.png and image2.png. im going to use load bitmap and get image to display the frames i want to see. the problem is i can't switch them. i attached my work and the images used. thanks in advance. i really would like to know the problem and how to do it.

KANRA || CINDY
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Nov 2011 17:02
Quote: "i attached my work and the images used."


A lot of that code looks like my code but it's ok.

Since your character sprite has been grabbed with GET IMAGE using individual image numbers (the frames) would be way different if you switched characters. So it'll definitely be harder to say Character #1 walk frames are images 1-8 and Character #2 walk frames are images 90-97 without using an array to store each characters frames and use the array any time you switch characters.

But don't freak out there is an easier way. If you use CREATE ANIMATED SPRITE you can still keep the old frame numbers that are hard coded in the code no matter what character you use. The only problem is you need to redo that sprite sheet so that the character lines up properly (so that each frame is exactly the same size) and any new characters you use in different files have to use exactly the same frame numbers for each state of movement (walking is the first 8 frames, jumping is the next 10, and so on). Once you use CREATE ANIMATED SPRITE you no longer use different image numbers... you use one image for them all but are still able to change frames.



SpoonAndFork
14
Years of Service
User Offline
Joined: 9th Oct 2011
Location:
Posted: 7th Nov 2011 22:02
Oops. Sorry for that I'll be careful now.

So, can i have more than 1 character displaying in the window? So it will look like a two player game?

KANRA || CINDY
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Nov 2011 23:03
It's ok. I posted that code on here to help somebody and it's perfectly acceptable to use by anybody.

Quote: "So, can i have more than 1 character displaying in the window? So it will look like a two player game?"


Yeah. I thought you were talking about using more than one character for the player. If you want two players on the screen at once you'll have to do the array thing I mentioned earlier or make more IF/THEN checks for the other player using the other players frame numbers. I don't have a lot of time right now but I'll post an example later.

Login to post a reply

Server time is: 2026-07-10 16:33:45
Your offset time is: 2026-07-10 16:33:45