1
0
Fork 0

Graphics/Image: dont store PixelFormat, instead define a new enum for number of channels.

The image class has a strict internal representation so we dont need "format".
PixelFormat enum can be passed to functions that modify the pixel data (like setPixels()) so that a proper convertion can be done.
This commit is contained in:
Henrik Hautakoski 2020-10-22 13:05:41 +02:00
parent 6f9b33be8f
commit f7fcc2633c
4 changed files with 53 additions and 86 deletions

View file

@ -99,10 +99,7 @@ Glyph FreeTypeEngine::loadGlyph(unsigned int codepoint, Image& img, unsigned int
FT_Glyph_To_Bitmap(&glyph_info, FT_RENDER_MODE_NORMAL, 0, true);
FT_Bitmap& bmp = reinterpret_cast<FT_BitmapGlyph>(glyph_info)->bitmap;
img.create(PixelFormat::PF_Alpha,
bmp.width,
bmp.rows,
bmp.buffer);
img.create(bmp.width, bmp.rows, bmp.buffer, PixelFormat::PF_Alpha);
glyph.offset.x = static_cast<unsigned char>(metrics.horiBearingX / (1 << 6));
glyph.offset.y = static_cast<unsigned char>(metrics.horiBearingY / (1 << 6));