1. Re: BitBlt
John DeHope wrote:
>First off you need a generic blitting procedure, which is basically a
>wrapper for EMemCopy.
I would *love* to have a general blitter for Euphoria - especially one that
handles all the graphics modes!
But from my ancient experiments with trying to turn EMemCopy into a general
blitter, it seemed that it was limited in the number of graphic modes it
addressed, and didn't work in the ones I care about. This seems to be
confirmed by Jiri's comments.
I've *whined* for Robert to add a blitter to Euphoria, and for Pete to
*pleeeze* code me up one in assembly...
I put together a generic blitter (included), but it's obviously slow. WinMan
was based on an optimized version of this blitter, that understood 0 in the
argument to be a screen, and handled clipping better. However, this version
*is* generic.
I'd love to see a generic blitter added to the core Euphoria routines.
-- David Cuny
-- generic bit blitter
global constant
CopyROP = 1, -- dst = src
OrROP = 2, -- dst = dst OR src
XorROP = 3, -- dst = dst XOR src
EraseROP = 4, -- dst = (NOT src) AND dst
NotCopyROP = 5, -- dst = NOT src
NotOrROP = 6, -- dst = (NOT src) OR dst
NotXorROP = 7, -- dst = (NOT src) XOR dst
NotEraseROP = 8, -- dst = src AND dst
NotROP = 9 -- dst = NOT dst
function opPixels( integer rop, integer src, integer dst )
if rop = CopyROP then return src
elsif rop = OrROP then return or_bits(dst, src)
elsif rop = XorROP then return xor_bits(dst, src)
elsif rop = EraseROP then return and_bits( not(src), dst)
elsif rop = NotCopyROP then return not(src)
elsif rop = NotOrROP then return or_bits(not(src), dst)
elsif rop = NotXorROP then return xor_bits(not(src), dst)
elsif rop = NotEraseROP then return and_bits(src, dst)
elsif rop = NotROP then return not(dst)
end if
-- error: unspecified rop code
end function
global function bitBlt( sequence dst, integer dx, integer dy,
sequence src, integer sx, integer sy,
integer sw, integer sh, integer rop )
-- this function copies a block of pixels from one bitmap to
-- another. bitBlt means bit block transfer.
-- arguments:
--
-- dst the device to copy to
-- dx, dy the position to copy to
-- src the device to copy from
-- sx, sy the position to copy from
-- sw, sh the width and height of the block to be copied
-- rop raster operation to be used when doing copying
--
-- this can obviously be specialized to operate *much* faster
-- avoid lots of -1's in the calculations
dx = dx - sx
dy = dy - sy
sh = sh - 1
sw = sw - 1
for y = sy to sy+sh do
for x = sx to sx+sw do
dst[dy+y][dx+x] = opPixels( rop, src[y][x], dst[dy+y][dx+x] )
end for
end for
return dst
end function