ref: 30034932cea9e2e37d781763d36b06607b8337be
parent: 595741f11dc91377adf4093b88abccb5b1b30660
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Mon Aug 13 16:31:59 EDT 2001
Fix image stride calculation, and generate a simpler (checkerboard) test pattern. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@36 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -8,7 +8,7 @@
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- $Id: jbig2_image.c,v 1.1 2001/08/10 23:29:28 giles Exp $
+ $Id: jbig2_image.c,v 1.2 2001/08/13 20:31:59 giles Exp $
*/
#include <stdio.h>
@@ -30,7 +30,7 @@
return NULL;
}
- stride = ((width - 1) >> 5) + 1; /* generate a word-aligned stride */
+ stride = (((width - 1) >> 5) + 1) << 2; /* generate a word-aligned stride */
image->data = malloc(stride*height);
if (image->data == NULL) {
fprintf(stderr, "jbig2dec error: could not allocate image data buffer!\n");
--- a/png_image.c
+++ b/png_image.c
@@ -8,7 +8,7 @@
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- $Id: png_image.c,v 1.2 2001/08/11 06:46:15 giles Exp $
+ $Id: png_image.c,v 1.3 2001/08/13 20:31:59 giles Exp $
*/
#include <stdio.h>
@@ -94,16 +94,17 @@
uint32 *data;
char *filename = "test.png";
- image = jbig2_image_new(256,128);
+ image = jbig2_image_new(400,400);
if (image == NULL) {
fprintf(stderr, "failed to create jbig2 image structure!\n");
exit(1);
}
+ fprintf(stderr, "creating checkerboard test image '%s'\n", filename);
data = image->data;
- for (j = 0; j < image->stride; j++) {
- for (i = 0; i < image->height; i++) {
- *data++ = (i+j % 2) * 0xF0F0F0F0;
+ for (j = 0; j < image->height; j++) {
+ for (i = 0; i < image->stride >> 2; i++) {
+ *data++ = ((j & 16) >> 4) ? 0x0000FFFF: 0xFFFF0000;
}
}