summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-03-17 08:50:28 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 09:58:19 +0100
commit0e7452a9e12483f29829461fd68a6f1eab6995e5 (patch)
tree5a472e29b52498fd56267f95d771a665a64a7646 /src
parent580a893d2eb25ae47556d2ec8bc4b32bb8eaa55a (diff)
eet: encode lossy image with AGRY88 or GRY8 whenever possible.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eet/eet_image.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/eet/eet_image.c b/src/lib/eet/eet_image.c
index 1e06cf6..f94bc59 100644
--- a/src/lib/eet/eet_image.c
+++ b/src/lib/eet/eet_image.c
@@ -1160,8 +1160,43 @@ _eet_data_image_rgb_encode(const void *data,
1160 void *d = NULL; 1160 void *d = NULL;
1161 size_t sz = 0; 1161 size_t sz = 0;
1162 JSAMPROW *jbuf; 1162 JSAMPROW *jbuf;
1163 unsigned int *grey;
1163 unsigned char *buf; 1164 unsigned char *buf;
1164 1165
1166 /* Try to encode this buffer as GRY8 or AGRY88.
1167 It is difficult to know if a different approach
1168 would have payed of, but for now I do walk and
1169 copy the pixels as long as they are grey. If I
1170 manage to copy them up to the end, I will be
1171 able to encode them as a GRY8 texture.
1172 */
1173 grey = malloc(sizeof (int) * w * h);
1174 if (grey)
1175 {
1176 const unsigned int *pixels = data;
1177 unsigned int i;
1178
1179 for (i = 0; i < w * h; i++)
1180 {
1181 uint8_t r, g, b;
1182
1183 r = R_VAL(&pixels[i]);
1184 g = G_VAL(&pixels[i]);
1185 b = B_VAL(&pixels[i]);
1186 if (!(r == g && g == b))
1187 break ;
1188 grey[i] = r << 24;
1189 }
1190
1191 if (i == w * h)
1192 {
1193 d = _eet_data_image_grey_encode(grey, w, h, quality, size);
1194 free(grey);
1195 return d;
1196 }
1197 free(grey);
1198 }
1199
1165 buf = alloca(3 * w); 1200 buf = alloca(3 * w);
1166 1201
1167 memset(&cinfo, 0, sizeof (struct jpeg_compress_struct)); 1202 memset(&cinfo, 0, sizeof (struct jpeg_compress_struct));