summaryrefslogtreecommitdiffstats
path: root/src/bmpjpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bmpjpeg.c')
-rw-r--r--src/bmpjpeg.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/bmpjpeg.c b/src/bmpjpeg.c
new file mode 100644
index 0000000..3d76e70
--- /dev/null
+++ b/src/bmpjpeg.c
@@ -0,0 +1,142 @@
+#include "color.h"
+
+void BMPto8x8AndYCbCr(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset, unsigned char depth ,unsigned char *Image, unsigned char *blok8x8)
+{
+ unsigned char i;
+ int x,y,Start_point;
+ depth = depth/8;
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x))*depth;
+ for(i=0;i<(64*depth);i+=depth)
+ {
+ if((i%8)==0) printf("\n");
+ if((Start_y+(i/(8*depth))) < ImageSize_y)
+ {
+ if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ {
+ if(depth == 3)
+ {
+ RGB2YCbCr(Image[Start_point+(i%(8*depth)) -(i/(8*depth))*(ImageSize_x*depth)],
+ Image[Start_point+(i%(8*depth))+1-(i/(8*depth))*(ImageSize_x*depth)],
+ Image[Start_point+(i%(8*depth))+2-(i/(8*depth))*(ImageSize_x*depth)],
+ &blok8x8[i],&blok8x8[i+1],&blok8x8[i+2]);
+
+ printf("%02x%02x%02x|",blok8x8[i+0],blok8x8[i+1],blok8x8[i+2]);
+ }
+ if(depth == 1)
+ {
+ blok8x8[i+0] = Image[Start_point+(i%(8*depth))-(i/(8*depth))*(ImageSize_x*depth)];
+ printf("%02x ",blok8x8[i]);
+ }
+ }
+ }
+ else
+ i = (64*depth);
+ }
+}
+
+void YCbCrAnd8x8toBMP(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset, unsigned char depth ,unsigned char *Image, unsigned char *blok8x8)
+{
+ unsigned char i;
+ int x,y,Start_point;
+ depth = depth/8;
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x))*depth;
+ for(i=0;i<(64*depth);i+=depth)
+ {
+ if((i%8)==0) printf("\n");
+ if((Start_y+(i/(8*depth))) < ImageSize_y)
+ {
+ if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ {
+ if(depth == 3)
+ {
+ YCbCr2RGB(blok8x8[i+0],blok8x8[i+1],blok8x8[i+2],
+ &Image[Start_point+(i%(8*depth)) -(i/(8*depth))*(ImageSize_x*depth)],
+ &Image[Start_point+(i%(8*depth))+1-(i/(8*depth))*(ImageSize_x*depth)],
+ &Image[Start_point+(i%(8*depth))+2-(i/(8*depth))*(ImageSize_x*depth)]);
+
+ printf("%02x%02x%02x|",blok8x8[i+0],blok8x8[i+1],blok8x8[i+2]);
+ }
+ if(depth == 1)
+ {
+ Image[Start_point+(i%(8*depth))-(i/(8*depth))*(ImageSize_x*depth)] = blok8x8[i+0];
+ printf("%02x ",blok8x8[i]);
+ }
+ }
+ }
+ else
+ i = (64*depth);
+ }
+
+}
+
+/*****************************
+The code without the RGB - > YUV
+******************************
+
+void BMPto8x8(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset, unsigned char depth ,unsigned char *Image, unsigned char *blok8x8)
+{
+ unsigned char i;
+ int x,y,Start_point;
+ depth = depth/8;
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x))*depth;
+ for(i=0;i<(64*depth);i+=depth)
+ {
+ if((i%8)==0) printf("\n");
+ if((Start_y+(i/(8*depth))) < ImageSize_y)
+ {
+ if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ {
+ if(depth == 3)
+ {
+ blok8x8[i+2] = Image[Start_point+(i%(8*depth)) -(i/(8*depth))*(ImageSize_x*depth)]; //R
+ blok8x8[i+1] = Image[Start_point+(i%(8*depth))+1-(i/(8*depth))*(ImageSize_x*depth)]; //G
+ blok8x8[i+0] = Image[Start_point+(i%(8*depth))+2-(i/(8*depth))*(ImageSize_x*depth)]; //B
+ printf("%02x%02x%02x|",blok8x8[i+0],blok8x8[i+1],blok8x8[i+2]);
+ }
+ if(depth == 1)
+ {
+ blok8x8[i+0] = Image[Start_point+(i%(8*depth))-(i/(8*depth))*(ImageSize_x*depth)];
+ printf("%02x ",blok8x8[i]);
+ }
+ }
+ }
+ else
+ i = (64*depth);
+ }
+}
+
+void B8x8toBMP(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset, unsigned char depth ,unsigned char *Image, unsigned char *blok8x8)
+{
+ unsigned char i;
+ int x,y,Start_point;
+ depth = depth/8;
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x))*depth;
+ for(i=0;i<(64*depth);i+=depth)
+ {
+ if((i%8)==0) printf("\n");
+ if((Start_y+(i/(8*depth))) < ImageSize_y)
+ {
+ if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ {
+ if(depth == 3)
+ {
+ Image[Start_point+(i%(8*depth)) -(i/(8*depth))*(ImageSize_x*depth)] = blok8x8[i+2]; //R
+ Image[Start_point+(i%(8*depth))+1-(i/(8*depth))*(ImageSize_x*depth)] = blok8x8[i+1]; //G
+ Image[Start_point+(i%(8*depth))+2-(i/(8*depth))*(ImageSize_x*depth)] = blok8x8[i+0]; //B
+ printf("%02x%02x%02x|",blok8x8[i+0],blok8x8[i+1],blok8x8[i+2]);
+ }
+ if(depth == 1)
+ {
+ Image[Start_point+(i%(8*depth))-(i/(8*depth))*(ImageSize_x*depth)] = blok8x8[i+0];
+ printf("%02x ",blok8x8[i]);
+ }
+ }
+ }
+ else
+ i = (64*depth);
+ }
+
+}
+
+*/
+