Lightning-Fast Bitmap Cropping

new topic     » topic index » view thread      » older message » newer message

I'm coding like hell right now, and I had to come up with a way to crop (ie.
clip) a standard Euphoria bitmap.
I wrote a routine that I think is lightning-fast.
I has only being tested on a 640*22 bitmap, so maybe it's slow on larger
bitmaps (???).
If you don't know what cropping is, it's cutting out a rectangular area from
a bitmap, and saving that area.
You can use this to perform clipping aswell.
Here it is, try it out with Euphoria 2.0+, and tell me if it explodes your
keyboard;

global function crop_image(sequence bmp,sequence rect)
sequence ret
integer y
ret = repeat(repeat(0,rect[3]-rect[1]),rect[4]-rect[2])
y = 1

for i = rect[2] to rect[4]-1 do -- To the height of the cropping rect
    ret[y][1..rect[3]-rect[1]] = bmp[2][i][rect[1]..rect[3]-1]
    y = y + 1
end for
return ret
end function


Mike The Spike

PS. Use


Back to code-code-code!!
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu