Re: NEIL HELP NEEDED!
- Posted by jiri babor <jbabor at PARADISE.NET.NZ> Nov 29, 2000
- 446 views
ck wrote: >1. How do I load a bitmap then extract individual bitmaps from it? >(For instance, I have 15 64x64 tiles in the one bitmap file, and I >want to extract all of them to a tiles[] sequence.) For 8-bit bitmaps it is pretty trivial, just follow the bloody manual. You can use the standard read_bitmap function. If the read is successful, you will get a two element sequence. The first element is the palette, and the second is a 2-d sequence of pixels colors. Each row represents a line of pixels in the image. Obviously, if you want to extract individual images from a combined one, you have to know, how they are stored. If you are not sure, just use any old graphics program, or load it into a simple euphoria program and display it using display_image. If the images are stored sequentially, vertically, then your combined image will have most likely 15*64 sequences, each lot of 64 containing one individual image. Just chop it up. On the other hand, if the images are stored in parallel, horizontally, the you will have just 64 very long sequences that you will have to slice each into 15 subsequences of 64 pixels. Each such subsequence belongs to a different individual image. All you have to do is to accumulate them (using append) in appropriate containers (in elements of your tile sequence for instance). If the color depth of your images is more than 8 bits, I am sorry, I cannot help you. Being colorblind, 256 colors is more than I can really handle anyway. >2. There's no rotate_bitmap() function, it seems. How do I ROTATE a >graphic?! Even if I could just get the 2-d sequence using the handle, >then I could rotate that and replace it... I dug out a routine I wrote some time ago. It is attached at the bottom of this message. It is not particularly fast, but it will give you 20 to 50 frames per second with a smallish image on a modern machine. You can probably optimize it a little without too much effort, but to get anything much faster, you have to be a masochist and dirty your hands with a bit of assembly. Just one more, final remark. I think you mentioned Neil on a Win2k machine. I haven't got Win2k, but if it's a descendant of NT, just forget it. I believe the system will not allow you to fiddle with it at the low level Neil does. Best of luck. jiri -- file : rotate.e -- author : jiri babor -- date : 99-03-07 -- email : jbabor at paradise.net.nz -- topic : image rotation constant d2r=0.01745329 -- degrees to radians (pi/180) global function rotate( sequence s, -- rotated image, 2-d sequence atom a, -- angle of rotation, clockwise, in degrees integer c -- background, unused fill color ) -- rotate image in its own space about its cetre sequence rs,xca,xsa,yca,ysa atom ca,sa,xc,yc,x,y integer w,h h=length(s) -- image height w=length(s[1]) -- image width rs=repeat(repeat(c,w),h) xc=(w+1)/2 yc=(h+1)/2 a=d2r*a -- degrees to radians sa=sin(a) ca=cos(a) xca=repeat(ca,w) xsa=repeat(sa,w) for i=1 to w do xca[i]*=i-xc xsa[i]*=i-xc end for yca=repeat(ca,h) ysa=repeat(sa,h) for i=1 to h do yca[i]*=i-yc ysa[i]*=i-yc end for for i=1 to h do for j=1 to w do x=xca[j]+ysa[i]+xc+0.0001 -- (optional) compensation y=-xsa[j]+yca[i]+yc+0.0001 -- for ugly rounding errors -- x=xca[j]+ysa[i]+xc -- y=-xsa[j]+yca[i]+yc if x>1 and x<w+1 and y>1 and y<h+1 then rs[i][j]=s[y][x] end if end for end for return rs end function