freetype
[Top][All Lists]
Advanced

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

Re: [ft] need help with freetype + xlib.


From: Yves Daoust
Subject: Re: [ft] need help with freetype + xlib.
Date: Wed, 19 Jun 2013 11:49:37 +0200

To summarize, if I may: for an RGBA image having Height rows, each Width
pixels wide,

        Pitch = 4 x Width + Pad         (4 x 8 + 0 = 32 bytes per row)
        Size = Pitch x Height           (32 x 16 = 512 bytes per image)

-----Original Message-----
From: address@hidden
[mailto:address@hidden On
Behalf Of Glynn Clements
Sent: Tuesday, June 18, 2013 7:21 PM
To: First Last
Cc: address@hidden; address@hidden
Subject: Re: [ft] need help with freetype + xlib.


First Last wrote:

> Hi, I try to use freetype with xlib, I , I need to pass a char type 
> array (RGBA/pixel) to a xlib function.
> 
> from freetype I got :
> 
>   face->glyph->bitmap.pixel_mode = 2
> so if I understood corectly in face->glyph->bitmap.buffer datas are stored
in gray level.
>   face->glyph->bitmap.rows=16
>   face->glyph->bitmap.width=8
>   face->glyph->bitmap.pitch=8
> 
> so I guess,  length of face->glyph->bitmap.buffer = 1(gray 
> lvl)*16(width)*8(rows)=128 unsigned chars, right ?

Right answer, wrong reasoning; width should be replaced by pitch. The two
values may differ if there is padding between lines.

> then I create an array of char for xlib from 
> face->glyph->bitmap.buffer
> 
>   for(i=0;i<128;i++){
>     Xdata[4*i]     = face->glyph->bitmap.buffer[i];
>     Xdata[4*i+1] = face->glyph->bitmap.buffer[i];
>     Xdata[4*i+2] = face->glyph->bitmap.buffer[i];
>     Xdata[4*i+3] = 255;
>    } and I try to create a XImage :
>   ximage = XCreateImage(display, DefaultVisual(display,0), 24, 
> ZPixmap, 0,
>                                         &Xdata[0], 8/*rows*/, 
> 16/*width*/, 32/*RGBA*/, 8/*pitch??*/);


The last argument (bytes_per_line) should be 32 (8 pixels wide at 4 bytes
per pixel).

--
Glynn Clements <address@hidden>

_______________________________________________
Freetype mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/freetype




reply via email to

[Prev in Thread] Current Thread [Next in Thread]