Page 1 of 1

Bliting ....

Posted: Sun Jan 18, 2004 5:39 am
by Perica
..

Re:Blit-ing ....

Posted: Sun Jan 18, 2004 8:00 am
by Tim
Bit blt is short for Bit BLock Transfer (the I in blit is sometimes added for pronunciation). It's just a funny term for copying bytes. Something as simple as memcpy can do blts.

A graphics blt routine could implement transparency; there are many ways to do this. The most intuitive to me is:

Code: Select all

void transparent_copy(pixel *dest, const pixel *src, int num_pixels, pixel transparent)
{
    int i;
    for (i = 0; i < num_pixels; i++)
        if (src[i] != transparent)
            dest[i] = src[i];
}
The point of this is, you don't bother touching pixels that don't need to be modified. Also, this doesn't read from anywhere other than src. Typically dest will point to video memory and src will point to a bitmap of the mouse pointer in system memory. (Reads from video memory are really slow.)

Searching for sprite routines in graphics libraries (e.g. SDL or Allegro) should reveal some more techniques.

Re:Blit-ing ....

Posted: Sun Jan 18, 2004 9:04 am
by Candy
Tim Robinson wrote: Typically dest will point to video memory and src will point to a bitmap of the mouse pointer in system memory. (Reads from video memory are really slow.)
Then how would you suggest making a translucent mouse cursor? By copying the entire block from the video memory at once using some sort of proprietary bitblt or by reading each byte at a time? Which would be faster?

Re:Blit-ing ....

Posted: Sun Jan 18, 2004 9:46 am
by Tim
I would read the whole lot into system memory and then work from that copy, this being simpler.

I could only guess at which way would be faster; as always, write functions to do it both ways and profile them to see which works best.

Re:Blit-ing ....

Posted: Sun Jan 18, 2004 12:09 pm
by Schol-R-LEA
Graphics are not a strong area of mine, but it occurs to me that, unless you are using video acceleration, it may be both faster and easier to do all of the drawing in in system memory, and move the image (or the changes to it) to an off-screen page of video memory only after completion, then after that switch screen pages.

Perhaps you could even two levels in system memory, one of the last drawn version and a 'mask' with the changes. The changes calculated from the complete image, but written to the mask, then written to video memory as above, then the mask would be written to the complete version in system memory as well to update it for the next cycle. I seem to recall hearing of techniques like this before; is this something actually used in graphics programming already? Does it make sense?

Re:Blit-ing ....

Posted: Sun Jan 18, 2004 1:10 pm
by df
bit blitting i remember as an old term from amiga days when youd blit chunks in and out of amiga gfx memory and stuff...

the amiga had a coprocessor called the blitter chip, and using that to copy memory was 2 or 3 times more faster than using the 68k cpu to copy memory.. hence doing a bit blit was copying memory..