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.

Code Snippets / making an image into tiles

Author
Message
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 1st Jun 2006 02:57
Hello all,

Thought I would share a simple function that turns a bitmap into seperate images similar to create animated sprite.




Just noticed alot of times in peoples posted codes this is done manually with each image so figured I would post this to save some people some time.

no need to know the size of the image as long as you know number of tiles across and down. imagestart is the number of the first image created by the function.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jun 2006 16:30
I got an improvement for you:

What if I tell you: my screen res is 640,480,32. My image is 1024x1024...

This function would crash...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 4th Jun 2006 21:17 Edited at: 4th Jun 2006 21:18
Actually I just tested that and it works fine even with a different resolution.

I used this code



with the following image.

Thank you though if there had been a problem I would want to make sure to correct it.

Attachments

Login to view attachments
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jun 2006 22:41
Huh? I thought it was impossible to get an image outside the screen.

I'll have to relook on that point...

Anyway, srr...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 5th Jun 2006 01:12
perhaps if using bitmap 0? since it is the screen.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Jun 2006 13:34
Probably...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 7th Jun 2006 05:46
They actually fixed that in like 5.8 or 5.9 You can now capture parts of the bitmap outside the screen resolution as long as it is not bitmap 0.

Login to post a reply

Server time is: 2024-11-23 03:53:24
Your offset time is: 2024-11-23 03:53:24