freetype
[Top][All Lists]
Advanced

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

[ft] monochrome bitmap - smth. strange?


From: waterwall
Subject: [ft] monochrome bitmap - smth. strange?
Date: Sun, 18 Dec 2005 03:08:04 +0100

Hello
It the beging I want to thanks for previous help. I've just added -lfreetype as g++ flag and renamed file name freetype.a to libfreetype.a.
 
Now I've got another problem.
 
I've use code, that I've found here and I added something from myself (TTiff.h). It should put bytes from character ('A') to array of chars (myFile) and save it as monochrome bitmap. This is a code:
 
 
#include <iostream>
#include <ft2build.h>
#include FT_FREETYPE_H
#include "TTiff.h"
 
using namespace std;
 
int main(int argc, char *argv[]){
    TTiff chart;
    chart.outputFileName = "a.tif";
    FT_Library library;
    FT_Face face;
    FT_Init_FreeType (&library);
    FT_New_Face(library, "arial.ttf", 0, &face);
    FT_Set_Pixel_Sizes(face, 16, 16);
    FT_Load_Glyph(face, FT_Get_Char_Index(face, 'A'), 0);
    FT_Render_Glyph(face -> glyph, FT_RENDER_MODE_MONO);
    char *pointer;
    for (int nY = 0; nY < face -> glyph -> bitmap.rows; nY++){
        pointer = chart.myFile + chart.getWidth () / 8 * nY;
        for (int nX = 0; nX < face -> glyph -> bitmap.width; nX++ ){
            *pointer = face -> glyph -> bitmap.buffer[(nY * face -> glyph -> bitmap.pitch) + (nX >> 3)];
            if ((nX + 1) % (face -> glyph -> bitmap.pitch) == 0)
                pointer++;
        }
    }
    chart.saveImage ();
}
 
Library TTiff.h is using libtiff. myFile is array of char[width/8*height] (8 pixel is one byte). Result is strange:
http://waterwall.konst.pl/users/ja/images/a.tif
 
Could you tell me, where I've do something wrong?

reply via email to

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