#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
#include "tb1.h"
|
#include "tb1.h"
|
|
|
unsigned char* jpgimage;
|
unsigned char* jpgimage;
|
unsigned long jpgsize;
|
unsigned long jpgsize;
|
unsigned char* bmpimage;
|
unsigned char* bmpimage;
|
unsigned long bmpsize;
|
unsigned long bmpsize;
|
|
|
int main() {
|
int main() {
|
SYSACE_FILE *jpgfile;
|
SYSACE_FILE *jpgfile;
|
SYSACE_FILE *bmpfile;
|
SYSACE_FILE *bmpfile;
|
int i, numread, numwrite;
|
int i, numread, numwrite;
|
|
|
jpgsize = bmpsize = 0;
|
jpgsize = bmpsize = 0;
|
jpgimage = (unsigned char*)JPG_ADDRESS;
|
jpgimage = (unsigned char*)JPG_ADDRESS;
|
bmpimage = (unsigned char*)BMP_ADDRESS;
|
bmpimage = (unsigned char*)BMP_ADDRESS;
|
|
|
if ((jpgfile = sysace_fopen("image01.jpg", "r")) == NULL) {
|
if ((jpgfile = sysace_fopen("image01.jpg", "r")) == NULL) {
|
xil_printf("Error in opening input file\r\n");
|
xil_printf("Error in opening input file\r\n");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
for (i = 0; i<JPG_MAXSIZE; i++) {
|
for (i = 0; i<JPG_MAXSIZE; i++) {
|
numread = sysace_fread(jpgimage+i, 1, 1, jpgfile);
|
numread = sysace_fread(jpgimage+i, 1, 1, jpgfile);
|
if (numread == 0) break;
|
if (numread == 0) break;
|
}
|
}
|
|
|
sysace_fclose(jpgfile);
|
sysace_fclose(jpgfile);
|
|
|
if (i==JPG_MAXSIZE) {
|
if (i==JPG_MAXSIZE) {
|
xil_printf("Input file exceeds max size\r\n");
|
xil_printf("Input file exceeds max size\r\n");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
jpgsize = i;
|
jpgsize = i;
|
|
|
memcpy(bmpimage, jpgimage, jpgsize);
|
memcpy(bmpimage, jpgimage, jpgsize);
|
bmpsize = jpgsize;
|
bmpsize = jpgsize;
|
|
|
if ((bmpfile = sysace_fopen("image01.bmp", "w")) == NULL) {
|
if ((bmpfile = sysace_fopen("image01.bmp", "w")) == NULL) {
|
xil_printf("Error in opening output file\r\n");
|
xil_printf("Error in opening output file\r\n");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
numwrite = sysace_fwrite(bmpimage, 1, bmpsize, bmpfile);
|
numwrite = sysace_fwrite(bmpimage, 1, bmpsize, bmpfile);
|
|
|
sysace_fclose(bmpfile);
|
sysace_fclose(bmpfile);
|
|
|
if (numwrite != bmpsize) {
|
if (numwrite != bmpsize) {
|
xil_printf("Error in writing output file\r\n");
|
xil_printf("Error in writing output file\r\n");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
return 0;
|
return 0;
|
|
|
}
|
}
|
|
|