[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 57a3791 08/22: [graph] Handle mono bitmaps in t
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master 57a3791 08/22: [graph] Handle mono bitmaps in the main blender. |
Date: |
Fri, 5 Mar 2021 11:18:38 -0500 (EST) |
branch: master
commit 57a379161d19e67235936ab824ade58a2a88f46a
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[graph] Handle mono bitmaps in the main blender.
* graph/gblany.h (_gblender_blit_mono_*): Implement it.
* graph/gblblit.c (gblender_blit_init): Recognize mono bitmaps.
* graph/gblblit.h (GBlenderSourceFormat): Add GBLENDER_SOURCE_MONO.
---
ChangeLog | 8 ++++++++
graph/gblany.h | 45 ++++++++++++++++++++++++++++++++++++++++++++-
graph/gblblit.c | 5 ++---
graph/gblblit.h | 1 +
4 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f36e629..e10f978 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-01-25 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [graph] Handle mono bitmaps in the main blender.
+
+ * graph/gblany.h (_gblender_blit_mono_*): Implement it.
+ * graph/gblblit.c (gblender_blit_init): Recognize mono bitmaps.
+ * graph/gblblit.h (GBlenderSourceFormat): Add GBLENDER_SOURCE_MONO.
+
2021-01-24 Alexei Podtelezhnikov <apodtele@gmail.com>
* Makefile (FT_INCLUDES): Drop `$(TOP_DIR)/src/dlg`.
diff --git a/graph/gblany.h b/graph/gblany.h
index 917a750..c95df78 100644
--- a/graph/gblany.h
+++ b/graph/gblany.h
@@ -476,6 +476,48 @@ GCONCAT( _gblender_blit_bgra_, GDST_TYPE )( GBlenderBlit
blit,
}
+static void
+GCONCAT( _gblender_blit_mono_, GDST_TYPE )( GBlenderBlit blit,
+ grColor color )
+{
+ int h = blit->height;
+ unsigned char* dst_line = blit->dst_line + blit->dst_x*GDST_INCR;
+ const unsigned char* src_line = blit->src_line + ( blit->src_x >> 3 );
+ unsigned int src_mask = 0x80 >> ( blit->src_x & 7 );
+
+ do
+ {
+ const unsigned char* src = src_line;
+ unsigned int a8 = *src;
+ unsigned int msk = src_mask;
+ unsigned char* dst = dst_line;
+ int w = blit->width;
+
+ do
+ {
+ if ( !msk )
+ {
+ a8 = *++src;
+ msk = 0x80;
+ }
+
+ if ( a8 & msk )
+ {
+ GDST_COPY(dst);
+ }
+
+ msk >>= 1;
+ dst += GDST_INCR;
+ }
+ while (--w > 0);
+
+ src_line += blit->src_pitch;
+ dst_line += blit->dst_pitch;
+ }
+ while (--h > 0);
+}
+
+
static const GBlenderBlitFunc
GCONCAT( blit_funcs_, GDST_TYPE )[GBLENDER_SOURCE_MAX] =
{
@@ -484,7 +526,8 @@ GCONCAT( blit_funcs_, GDST_TYPE )[GBLENDER_SOURCE_MAX] =
GCONCAT( _gblender_blit_hbgr_, GDST_TYPE ),
GCONCAT( _gblender_blit_vrgb_, GDST_TYPE ),
GCONCAT( _gblender_blit_vbgr_, GDST_TYPE ),
- GCONCAT( _gblender_blit_bgra_, GDST_TYPE )
+ GCONCAT( _gblender_blit_bgra_, GDST_TYPE ),
+ GCONCAT( _gblender_blit_mono_, GDST_TYPE )
};
diff --git a/graph/gblblit.c b/graph/gblblit.c
index 7b66fb0..0bc81df 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -262,9 +262,6 @@ gblender_blit_init( GBlenderBlit blit,
int dst_height = target->rows;
- if ( glyph->grays != 256 )
- return -2;
-
switch ( glyph->mode )
{
case gr_pixel_mode_gray: src_format = GBLENDER_SOURCE_GRAY8;
@@ -288,6 +285,8 @@ gblender_blit_init( GBlenderBlit blit,
break;
case gr_pixel_mode_bgra: src_format = GBLENDER_SOURCE_BGRA;
break;
+ case gr_pixel_mode_mono: src_format = GBLENDER_SOURCE_MONO;
+ break;
default:
return -2;
}
diff --git a/graph/gblblit.h b/graph/gblblit.h
index 9143870..246df6f 100644
--- a/graph/gblblit.h
+++ b/graph/gblblit.h
@@ -17,6 +17,7 @@ typedef enum
GBLENDER_SOURCE_VRGB,
GBLENDER_SOURCE_VBGR,
GBLENDER_SOURCE_BGRA,
+ GBLENDER_SOURCE_MONO,
GBLENDER_SOURCE_MAX
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 57a3791 08/22: [graph] Handle mono bitmaps in the main blender.,
Werner Lemberg <=