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! / grabbing tiles from an image

Author
Message
RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 1st May 2003 04:29
Hi,i need a small nested loop to grab all possible 32x32 tiles from a bitmap sized 640*604 with get image command!! Please help! and thanx
RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 1st May 2003 04:48
ooops..typo..i meant 640x640!

CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 1st May 2003 06:11
image_number = 0
for x = 0 to 19
for y = 0 to 19
inc image_number,1
get image image_number,x*32,y*32,x*32+32,y*32+32,1
next y
next x

RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 1st May 2003 06:30
hmmm.i tried that just now..doesnt work..p.s i dunno what the ,1 param were.. but it isnt need! its just get image x1,y1,x2,y2
anyhow i get 'cannot grab image due to illegal area with that code!!

RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 1st May 2003 06:31
err.. Get Image imagenum,x1,y1,x2,y2 rather!

RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 1st May 2003 06:35 Edited at: 1st May 2003 06:39
ok..this works!
for x = 0 to 19
for y = 0 to 14
inc image_number,1
get image image_number,x*32,y*32,(x*32)+32,(y*32)+32
next y
next x

the whole function...


function _loadimages()
load image "cursor.bmp",200
load image "blank.bmp",300
load image "tiles.bmp",60
create bitmap 3,640,640
set current bitmap 3
paste image 60,0,0
image_number = 0
for x = 0 to 19
for y = 0 to 14
inc image_number,1
get image image_number,x*32,y*32,(x*32)+32,(y*32)+32
next y
next x
set current bitmap 0
endfunction



it just needed lower values..odd..can any1 explain..p.s. Thanx closetoperfect for gettin me on track!

heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 1st May 2003 08:09 Edited at: 1st May 2003 08:13
Your spec calls for ALL POSSIBLE 32x32 pixel bitmaps in a 640x480 bitmap. That is 369,664 (608*608) bitmaps. Why do you need so many? Can your system even handle that many? Perhaps you actually meant to say the bitmaps with their origins on the zero modulo 32 grid?

The more you see, the more you know.
The more you know, the more you see.
Cras
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: United Kingdom
Posted: 1st May 2003 15:03
i think he means divide it up into 32x32 squares so cynical
RaverDave
20
Years of Service
User Offline
Joined: 30th Apr 2003
Location:
Posted: 2nd May 2003 02:56 Edited at: 2nd May 2003 02:56
arrrf..hehe..well my spec is super fine thanks...but all i am doing is making a tile editor! so you design your levels using tiles and save them out as a data file..to be loaded in and..blahblah!

i have a 1 gig amd athlon..but it helps to have 500 meg of ram these days..which i have!(sighs) the age of computing..

CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 2nd May 2003 07:40
are you using DBC or DBP, the ,1 is for DBP it's a texture flag that make the image look less blurry.

why is your y on;y 0 to 14 thats on 15x32 or 480 not 640, thought you wanted 640x640?

is you origonal image not 640x640? thats the only thing I could think of. It must be 640 wide as 32 x 20 is 640

CTP

Login to post a reply

Server time is: 2024-04-19 22:35:23
Your offset time is: 2024-04-19 22:35:23