[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How Do I Draw A Bitmap?



Hi Havoc,

Thanks for the reply.

At 07:43 PM 7/11/2001, Havoc Pennington wrote:

>Eric Mader <mader@jtcsv.com> writes:
> >
> > I'm trying to write a little GNOME application to test a 3rd party
> > font scaler; I've got as far as getting the bitmaps for the
> > characters from the scaler, but I can't find a way to draw them.
>
>Somehow I doubt the bitmaps are GdkBitmaps. What is the exact type and
>format of these bitmaps?

The scaler returns an array of bits, one per pixel. I can control whether 
or not it pads a row to a multiple of one, two or four bytes. I've got it 
set to not pad. I was using gdk_bitmap_create_from_data() to make the 
GdkBitmap.

 From the sample code I have, it looks like this takes an array of bits as 
I get them from the scaler. Have I missed something?


> > The first thing I tried was gdk_draw_bitmap(). When I link my
> > application, that symbol doesn't get resolved.
>
>That's because it doesn't exist. ;-)

So I gathered, but it *is* in gdk.h, so you can't blame me for expecting it 
to be there...


> > (On a whim I tried to use gdk_draw_pixmap() instead; that prints out
> > some strange messages about incompatible parameters and exits - I
> > assume because the bitmap is the wrong depth?)
>
>Bitmaps are simply 1-bit pixmaps. Most drawables will be 8-bit or
>24-bit.
>
>The depth refers to the size of a pixel. So in bitmaps, each pixel is
>on or off, one bit. Color displays use a lot more bits per pixel.
>
>gdk_draw_pixmap() simply copies blocks of memory around; if you don't
>have matching depths then nothing logical happens. Each 8 or 24 pixels
>in the bitmap would make up one color pixel with a random ugly color.
>So this is not allowed.
>
>Assuming you actually had a GdkBitmap, which seems unlikely from a 3rd
>party font scaler, the way you would typically draw it would be to set
>it as a clip mask (gdk_gc_set_clip_mask()), then draw a rectangle.

Well, if I don't have a GdkBitmap, and can't easily make one from the bits 
I get from the scaler, what do I do?


>Havoc


Eric






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]