summaryrefslogtreecommitdiffstats
path: root/src/bmpjpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bmpjpeg.c')
-rw-r--r--src/bmpjpeg.c102
1 files changed, 32 insertions, 70 deletions
diff --git a/src/bmpjpeg.c b/src/bmpjpeg.c
index 66e34b2..e8470e7 100644
--- a/src/bmpjpeg.c
+++ b/src/bmpjpeg.c
@@ -1,72 +1,34 @@
-#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, int *blok8x8)
+void BMPto8x8AndYCbCr(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset, unsigned char *Image, int *blok8x8)
{
unsigned char i,color;
int x,y,Start_point;
-// printf("\nBMPto8x8AndYCbCr:\n");
- 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)
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x));
+ for(i=0;i<64;i++)
{
-// if((i%8)==0) printf("\n");
- if((Start_y+(i/(8*depth))) < ImageSize_y)
+ if((Start_y+(i/8)) < 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] = Image[Start_point+(i%(8*depth))-(i/(8*depth))*(ImageSize_x*depth)];
-// printf("%02x ",blok8x8[i]);
- }
- }
+ if((Start_x+(i%8)) < ImageSize_x)
+ blok8x8[i] = Image[Start_point+(i%8)-(i/8)*(ImageSize_x)];
}
else
- i = (64*depth);
+ i = 64;
}
}
-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)
+void YCbCrAnd8x8toBMP(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int offset,unsigned char *Image, unsigned char *blok8x8)
{
unsigned char i;
int x,y,Start_point;
-// printf("\nYCbCrAnd8x8toBMP:\n");
- 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)
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x));
+ for(i=0;i<64;i++)
{
-// if((i%8)==0) printf("\n");
- if((Start_y+(i/(8*depth))) < ImageSize_y)
+ if((Start_y+(i/8)) < 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];
-// printf("%02x ",blok8x8[i]);
- }
- }
+ if((Start_x+(i%8)) < ImageSize_x)
+ Image[Start_point+(i%8)-(i/8)*(ImageSize_x)] = blok8x8[i];
}
else
- i = (64*depth);
+ i = 64;
}
}
@@ -80,30 +42,30 @@ void BMPto8x8(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int of
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)
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x));
+ for(i=0;i<(64);i+=depth)
{
if((i%8)==0) printf("\n");
- if((Start_y+(i/(8*depth))) < ImageSize_y)
+ if((Start_y+(i/(8))) < ImageSize_y)
{
- if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ if((Start_x+((i%(8))/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
+ blok8x8[i+2] = Image[Start_point+(i%(8)) -(i/(8))*(ImageSize_x)]; //R
+ blok8x8[i+1] = Image[Start_point+(i%(8))+1-(i/(8))*(ImageSize_x)]; //G
+ blok8x8[i+0] = Image[Start_point+(i%(8))+2-(i/(8))*(ImageSize_x)]; //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)];
+ blok8x8[i+0] = Image[Start_point+(i%(8))-(i/(8))*(ImageSize_x)];
printf("%02x ",blok8x8[i]);
}
}
}
else
- i = (64*depth);
+ i = (64);
}
}
@@ -112,30 +74,30 @@ void B8x8toBMP(int Start_x, int Start_y, int ImageSize_x, int ImageSize_y, int o
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)
+ Start_point = offset + (ImageSize_x*(ImageSize_y-1)+Start_x-(Start_y*ImageSize_x));
+ for(i=0;i<(64);i+=depth)
{
if((i%8)==0) printf("\n");
- if((Start_y+(i/(8*depth))) < ImageSize_y)
+ if((Start_y+(i/(8))) < ImageSize_y)
{
- if((Start_x+((i%(8*depth))/depth)) < ImageSize_x)
+ if((Start_x+((i%(8))/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
+ Image[Start_point+(i%(8)) -(i/(8))*(ImageSize_x)] = blok8x8[i+2]; //R
+ Image[Start_point+(i%(8))+1-(i/(8))*(ImageSize_x)] = blok8x8[i+1]; //G
+ Image[Start_point+(i%(8))+2-(i/(8))*(ImageSize_x)] = 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];
+ Image[Start_point+(i%(8))-(i/(8))*(ImageSize_x)] = blok8x8[i+0];
printf("%02x ",blok8x8[i]);
}
}
}
else
- i = (64*depth);
+ i = (64);
}
}