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.

2D All the way! / image cropping

Author
Message
Tenbar
12
Years of Service
User Offline
Joined: 31st Mar 2010
Location:
Posted: 4th Apr 2010 03:14
I am trying to load a image that is 288x608. it\'s a .bmp file and I want to break it up and use 32x32 squares to populate a map. anyone know how I go that?

this is my code

Ashingda 27
14
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 4th Apr 2010 06:50
Learn how to use Bitmap. Type "Bitmap" into the editor click on it and press (F1). Try this first.
Tenbar
12
Years of Service
User Offline
Joined: 31st Mar 2010
Location:
Posted: 4th Apr 2010 11:17
Well not the help I was expecting..

looking at the help files is always the first thing I do as well as look at tutorials and such that I see on the forums.

Does anyone actually have any idea besides do the most common sense thing?
Ashingda 27
14
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 4th Apr 2010 22:51 Edited at: 4th Apr 2010 23:04
I was going to help you further after knowing if you've at least tried but seems you are ahead of me.

There are many ways to get this done and I'll show you 2 ways that I use.

1) Simply Load up a bitmap and just grab the images from that. You an have up to 32 different bitmaps, bitmaps can be at any size you desire as long as your machine can handle it but bitmap 0 is the screen and you cannot modify it because it is restricted to your display settings.



2) The second way I'll show you is to load the Tileset as an image and create a bitmap at the size of 32,32. The Tileset is offset and pasted onto the bitmap then grabbed into different tiles.


I've attached the image used for the example, remember to download that first before running the codes.

[edit]
I apologize I misunderstood you but the way to get it to work is also in the examples too.

Attachments

Login to view attachments
TDK
Retired Moderator
20
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Apr 2010 20:51
As Ashingda 27 says, you need to use Load Bitmap.

In your program, you are loading the image, but you aren't doing anything with it. You just needed a Paste Image to go with it.

But, the user can see that happen and if you don't want the operation to be seen, that's where Load Bitmap comes in.

There are 32 bitmaps available. 0 (zero) is always the one that you see on your monitor and 1-31 are all hidden.

When you load an image into a bitmap, DB always switches that bitmap to be the default one for all screen reading/writing operations, so when you have finished grabbing the small images, you need to use Set Current Bitmap 0 to make the main bitmap the default one again.

DB Tutorials For Beginners:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

TDK

Tenbar
12
Years of Service
User Offline
Joined: 31st Mar 2010
Location:
Posted: 5th Apr 2010 23:48
Well I have learned many things in this post.

1: I did not know you could have 32 different bitmap images up.
2: I did not know that you had to paste the image to the screen in order to get an image from it.
3: did not know about setting the bitmap back to 0 to make it the default one again.

Thank you very much Ashingda 27 and TDK you have answered my question better than expected
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Apr 2010 01:38
Quote: "2: I did not know that you had to paste the image to the screen in order to get an image from it."


You don't. Firstly, you don't need to paste it anywhere (let alone the screen) to get an image from it. You can load initially it as a bitmap, or into a memblock (but the latter is a far more advanced technique)

You GET IMAGE from a bitmap, not the screen. If the current bitmap is 0, then you are getting it from the screen, but that's only one of up to 32 bitmaps you can GET it from.

Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Apr 2010 17:05
I tend to go for 2.5D engines, basically 3D engines but limited to 2D. There's too many benefits to mention - but one that I will mention is sprites and plains can be UV mapped. Matrices can be UV mapped. Memblock matrices can be UV mapped. So all of those methods would avoid you having to chop up your image. It's so much easier when you can just change a single image and it covers a whole tileset.

Even old fashioned matrices are handy for this stuff, because you just set the matrix tile at X,Y to tile number N - pretty easy to make an editor - compared to other techniques it's incredibly straightforward.


Health, Ammo, and bacon and eggs!
TDK
Retired Moderator
20
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Apr 2010 21:26
Quote: "Quote: "2: I did not know that you had to paste the image to the screen in order to get an image from it."

You don't."


Actually, in the context we were talking, you do. When Tenbar says "you had to paste the image" he means only if you use Load Image.

But what you are saying is correct, I just don't think we are talking about the same thing.

So to clarify...

Tenbar was loading an image with Load Image in his program and trying to cut other images from it without using Paste Image. So in that context, to achieve the objective, you do have to use Paste Image first.

But, as we have both said, there are better methods to use where you don't have to paste anything.

Personally, for all the advantages of using 3D, I would agree that Van B's method is probably the best way to go.

TDK

Login to post a reply

Server time is: 2023-01-27 00:43:47
Your offset time is: 2023-01-27 00:43:47