* src/base/ftbitmap.c (FT_Bitmap_Convert): Improve. This commit completes argument checks and adds support for different flow directions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
diff --git a/ChangeLog b/ChangeLog
index c62b5f5..73c8eb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2014-11-21 Werner Lemberg <wl@gnu.org>
+ * src/base/ftbitmap.c (FT_Bitmap_Convert): Improve.
+
+ This commit completes argument checks and adds support for different
+ flow directions.
+
+2014-11-21 Werner Lemberg <wl@gnu.org>
+
* src/base/ftbitmap.c (FT_Bitmap_Copy): Improve.
This commit adds argument checks and support for different flow
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index b33afec..5dd33a2 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -471,12 +471,16 @@
FT_Error error = FT_Err_Ok;
FT_Memory memory;
- FT_Int source_pitch, target_pitch;
+ FT_Byte* s;
+ FT_Byte* t;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
+ if ( !source || !target )
+ return FT_THROW( Invalid_Argument );
+
memory = library->memory;
switch ( source->pixel_mode )
@@ -489,7 +493,7 @@
case FT_PIXEL_MODE_LCD_V:
case FT_PIXEL_MODE_BGRA:
{
- FT_Int pad, old_target_pitch;
+ FT_Int pad, old_target_pitch, target_pitch;
FT_ULong old_size;
@@ -530,17 +534,20 @@
error = FT_THROW( Invalid_Argument );
}
- source_pitch = source->pitch;
- if ( source_pitch < 0 )
- source_pitch = -source_pitch;
+ s = source->buffer;
+ t = target->buffer;
+
+ /* take care of bitmap flow */
+ if ( source->pitch < 0 )
+ s -= source->pitch * ( source->rows - 1 );
+ if ( target->pitch < 0 )
+ t -= target->pitch * ( target->rows - 1 );
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 2;
@@ -549,7 +556,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -586,8 +593,8 @@
}
}
- s += source_pitch;
- t += target_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;
@@ -597,10 +604,8 @@
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
{
- FT_Int width = source->width;
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_Int width = source->width;
+ FT_UInt i;
target->num_grays = 256;
@@ -609,8 +614,8 @@
{
FT_ARRAY_COPY( t, s, width );
- s += source_pitch;
- t += target_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;
@@ -618,9 +623,7 @@
case FT_PIXEL_MODE_GRAY2:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 4;
@@ -629,7 +632,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -661,8 +664,8 @@
}
}
- s += source_pitch;
- t += target_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;
@@ -670,9 +673,7 @@
case FT_PIXEL_MODE_GRAY4:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 16;
@@ -681,7 +682,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
/* get the full bytes */
@@ -700,8 +701,8 @@
if ( source->width & 1 )
tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 );
- s += source_pitch;
- t += target_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;
@@ -709,9 +710,7 @@
case FT_PIXEL_MODE_BGRA:
{
- FT_Byte* s = source->buffer;
- FT_Byte* t = target->buffer;
- FT_Int i;
+ FT_UInt i;
target->num_grays = 256;
@@ -720,7 +719,7 @@
{
FT_Byte* ss = s;
FT_Byte* tt = t;
- FT_Int j;
+ FT_UInt j;
for ( j = source->width; j > 0; j-- )
@@ -731,8 +730,8 @@
tt += 1;
}
- s += source_pitch;
- t += target_pitch;
+ s += source->pitch;
+ t += target->pitch;
}
}
break;