Adding white space in dctexample.
authorviric@llimona
Mon, 03 Dec 2007 00:04:44 +0100
changeset 226 259bb91b8c94
parent 225 96bc629baba9
child 227 f2a4f54d3fc8
Adding white space in dctexample.
src/dctexample.c
src/libjpegrest.h
--- a/src/dctexample.c	Sun Dec 02 23:35:40 2007 +0100
+++ b/src/dctexample.c	Mon Dec 03 00:04:44 2007 +0100
@@ -4,6 +4,11 @@
 
 #define PI 3.141592657
 
+/* This opens a 8x8 PGM file from argv[1], and stores
+ * a 64+7x64+7 PGM file with each DCT-IDCT result, considering
+ * only the coefficients from top-left until the concerning
+ * DCT-IDCT result. */
+
 static void mydct(float *in, float *out)
 {
     int x,y,u,v;
@@ -19,8 +24,7 @@
 
             sum = 0.;
             for (x=0; x < 8; ++x)
-                for (y=0; y < 8; ++y)
-                {
+                for (y=0; y < 8; ++y) {
                     float *iptr;
                     iptr = in+y*8+x;
 
@@ -96,8 +100,27 @@
         for (i=0; i < 8; ++i)
         {
             gsl_matrix *dest = bdest->m[0];
-            dest->data[(j+y*8)*dest->tda+x*8+i] = sub[j*8+i];
+            dest->data[(j+y*9)*dest->tda+x*9+i] = sub[j*8+i];
+        }
+
+    if (x < 7)
+        for (j=0; j < 8; ++j)
+        {
+            gsl_matrix *dest = bdest->m[0];
+            dest->data[(j+y*9)*dest->tda+x*9+8] = 255;
         }
+    if (y < 7)
+        for (i=0; i < 8; ++i)
+        {
+            gsl_matrix *dest = bdest->m[0];
+            dest->data[(8+y*9)*dest->tda+x*9+i] = 255;
+        }
+
+    if (y < 7 && x < 7)
+    {
+        gsl_matrix *dest = bdest->m[0];
+        dest->data[(8+y*9)*dest->tda+x*9+8] = 255;
+    }
 }
 
 int main(int argn, char **argv)
@@ -132,7 +155,7 @@
     mydct(input, input_dct);
     myidct(input_dct, input_test);
 
-    obmap = bitmap_alloc(1, 64, 64);
+    obmap = bitmap_alloc(1, 64+7, 64+7);
 
     for(j=0;j < 8; ++j)
         for(i=0;i < 8; ++i)
--- a/src/libjpegrest.h	Sun Dec 02 23:35:40 2007 +0100
+++ b/src/libjpegrest.h	Mon Dec 03 00:04:44 2007 +0100
@@ -50,7 +50,9 @@
 /* bitmap_pam.c */
 void bitmap_pam_init(int *argn, char **argv);
 int bitmap_stdio_pam_get(FILE *input, struct bitmap *bmap);
+int bitmap_stdio_pam_put(FILE *output, struct bitmap *bmap);
 int bitmap_filename_pam_get(const char *filename, struct bitmap *bmap);
+int bitmap_filename_pam_put(const char *filename, struct bitmap *bmap);
 
 /* bitmap_jpeg.c */
 enum jpeg_conditions