need help with freetype + xlib.

First Last begre1929 at yahoo.com
Mon Jun 17 10:30:20 PDT 2013


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 ?

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??*/);
  XPutImage(display,XP,gc,ximage,0,0,0,0,8/*rows*/,16/*width*/);                                       

unfornatly I got a segmentation fault at XPutImage, I'm stuck with this for two days now... I join the full code, to compile :
g++ testFT.cpp -lX11 -I/usr/include/freetype2 -lfreetype


-Nicoo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20130617/147e3739/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testFT.cpp
Type: text/x-c++src
Size: 1904 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20130617/147e3739/attachment.cpp>


More information about the xorg mailing list