URL
https://opencores.org/ocsvn/djpeg/djpeg/trunk
Subversion Repositories djpeg
Compare Revisions
- This comparison shows the changes necessary to convert path
/djpeg
- from Rev 9 to Rev 10
- ↔ Reverse comparison
Rev 9 → Rev 10
/trunk/c_model/convsim.c
0,0 → 1,108
////////////////////////////////////////////////////////////////////////////// |
#include <stdio.h> |
#include <stdlib.h> |
|
typedef unsigned short WORD; |
typedef unsigned long DWORD; |
typedef long LONG; |
|
typedef struct tagBITMAPINFOHEADER{ |
DWORD biSize; |
LONG biWidth; |
LONG biHeight; |
WORD biPlanes; |
WORD biBitCount; |
DWORD biCompression; |
DWORD biSizeImage; |
LONG biXPelsPerMeter; |
LONG biYPelsPerMeter; |
DWORD biClrUsed; |
DWORD biClrImportant; |
} BITMAPINFOHEADER, *PBITMAPINFOHEADER; |
|
////////////////////////////////////////////////////////////////////////////// |
|
////////////////////////////////////////////////////////////////////////////// |
int main(int argc, char *argv[]) |
{ |
unsigned char buff[4]; |
char data[256]; |
FILE *rfp,*wfp; |
|
unsigned long width; |
unsigned long height; |
unsigned long bitdata; |
unsigned char tbuff[4]; |
BITMAPINFOHEADER lpBi; |
|
unsigned char *image; |
unsigned int i; |
|
if((rfp = fopen(argv[1],"rb")) == NULL){ |
perror(0); |
exit(0); |
} |
|
if((wfp = fopen(argv[2],"wb")) == NULL){ |
perror(0); |
exit(0); |
} |
|
|
fgets(data,256,rfp); |
width = (unsigned int)strtol(data,NULL,10); |
fgets(data,256,rfp); |
height = (unsigned int)strtol(data,NULL,10); |
|
image = (unsigned char *)malloc(height*width*3); |
|
|
tbuff[0] = 'B'; |
tbuff[1] = 'M'; |
fwrite(tbuff,2,1,wfp); |
tbuff[3] = ((14 +40 +width * height * 3) >> 24) & 0xff; |
tbuff[2] = ((14 +40 +width * height * 3) >> 16) & 0xff; |
tbuff[1] = ((14 +40 +width * height * 3) >> 8) & 0xff; |
tbuff[0] = ((14 +40 +width * height * 3) >> 0) & 0xff; |
fwrite(tbuff,4,1,wfp); |
tbuff[1] = 0; |
tbuff[0] = 0; |
fwrite(tbuff,2,1,wfp); |
fwrite(tbuff,2,1,wfp); |
tbuff[3] = 0; |
tbuff[2] = 0; |
tbuff[1] = 0; |
tbuff[0] = 54; |
fwrite(tbuff,4,1,wfp); |
|
|
lpBi.biSize = 40; |
lpBi.biWidth = width; |
lpBi.biHeight = height; |
lpBi.biPlanes = 1; |
lpBi.biBitCount = 3*8; |
lpBi.biCompression = 0; |
lpBi.biSizeImage = width*height*3; |
lpBi.biXPelsPerMeter = 300; |
lpBi.biYPelsPerMeter = 300; |
lpBi.biClrUsed = 0; |
lpBi.biClrImportant = 0; |
fwrite(&lpBi,1,40,wfp); |
|
i = 0; |
while(!feof(rfp)){ |
if(i>=width*height) break; |
fgets(data,256,rfp); |
bitdata=strtol(data,NULL,16); |
image[((height-i/width-1)*width*3)+(i%width)*3+0] = (bitdata >> 0) & 0xff; |
image[((height-i/width-1)*width*3)+(i%width)*3+1] = (bitdata >> 8) & 0xff; |
image[((height-i/width-1)*width*3)+(i%width)*3+2] = (bitdata >> 16) & 0xff; |
i++; |
} |
fwrite(image,1,width*height*3,wfp); |
fclose(rfp); |
fclose(wfp); |
free(image); |
|
return 0; |
} |
trunk/c_model/convsim.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/c_model/convbtoh.c
===================================================================
--- trunk/c_model/convbtoh.c (nonexistent)
+++ trunk/c_model/convbtoh.c (revision 10)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////////
+#include
+#include
+
+//////////////////////////////////////////////////////////////////////////////
+// メイン関数
+//////////////////////////////////////////////////////////////////////////////
+int main(int argc, char *argv[])
+{
+ unsigned char buff[4];
+ char data[256];
+ FILE *rfp,*wfp;
+
+ if((rfp = fopen(argv[1],"rb")) == NULL){
+ perror(0);
+ exit(0);
+ }
+ if((wfp = fopen(argv[2],"wb")) == NULL){
+ perror(0);
+ exit(0);
+ }
+ while(!feof(rfp)){
+ fread(buff,1,4,rfp);
+ sprintf(data,"%02X%02X%02X%02X\n",buff[3],buff[2],buff[1],buff[0]);
+ fwrite(data,1,9,wfp);
+ }
+ fclose(rfp);
+ fclose(wfp);
+
+ return 0;
+}
trunk/c_model/convbtoh.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property