Example #1
0
 void decompose_ft_bitmap_gray8(const FT_Bitmap& bitmap,
                                int x, int y,
                                bool flip_y,
                                Rasterizer& ras,
                                Scanline& sl,
                                ScanlineStorage& storage)
 {
     int i, j;
     const int8u* buf = (const int8u*)bitmap.buffer;
     int pitch = bitmap.pitch;
     sl.reset(x, x + bitmap.width);
     storage.prepare(bitmap.width + 2);
     if(flip_y)
     {
         buf += bitmap.pitch * (bitmap.rows - 1);
         y += bitmap.rows;
         pitch = -pitch;
     }
     for(i = 0; i < bitmap.rows; i++)
     {
         sl.reset_spans();
         const int8u* p = buf;
         for(j = 0; j < bitmap.width; j++)
         {
             if(*p) sl.add_cell(x + j, ras.apply_gamma(*p));
             ++p;
         }
         buf += pitch;
         if(sl.num_spans())
         {
             sl.finalize(y - i - 1);
             storage.render(sl);
         }
     }
 }
Example #2
0
 void decompose_ft_bitmap_mono(const FT_Bitmap& bitmap,
                               int x, int y,
                               bool flip_y,
                               Scanline& sl,
                               ScanlineStorage& storage)
 {
     int i;
     const int8u* buf = (const int8u*)bitmap.buffer;
     int pitch = bitmap.pitch;
     sl.reset(x, x + bitmap.width);
     storage.prepare(bitmap.width + 2);
     if(flip_y)
     {
         buf += bitmap.pitch * (bitmap.rows - 1);
         y += bitmap.rows;
         pitch = -pitch;
     }
     for(i = 0; i < bitmap.rows; i++)
     {
         sl.reset_spans();
         bitset_iterator bits(buf, 0);
         int j;
         for(j = 0; j < bitmap.width; j++)
         {
             if(bits.bit()) sl.add_cell(x + j, cover_full);
             ++bits;
         }
         buf += pitch;
         if(sl.num_spans())
         {
             sl.finalize(y - i - 1);
             storage.render(sl);
         }
     }
 }