pls
This commit is contained in:
+21
-17
@@ -1,4 +1,5 @@
|
|||||||
#include "image/imgio.h"
|
#include "image/imgio.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <turbojpeg.h>
|
#include <turbojpeg.h>
|
||||||
@@ -93,6 +94,7 @@ ppm_save(const unsigned int* buf, const PPM img)
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("test 1");
|
||||||
fprintf(fptr, "P%c\n%d %d\n255\n", img.fmt, img.width, img.height);
|
fprintf(fptr, "P%c\n%d %d\n255\n", img.fmt, img.width, img.height);
|
||||||
if (img.fmt == '3')
|
if (img.fmt == '3')
|
||||||
{
|
{
|
||||||
@@ -108,6 +110,7 @@ ppm_save(const unsigned int* buf, const PPM img)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("test 2");
|
||||||
if (img.fmt == '6')
|
if (img.fmt == '6')
|
||||||
{
|
{
|
||||||
for (int i = 0; i < img.len; i++)
|
for (int i = 0; i < img.len; i++)
|
||||||
@@ -118,6 +121,7 @@ ppm_save(const unsigned int* buf, const PPM img)
|
|||||||
}
|
}
|
||||||
fwrite(dst_buf, 1, img.len * 3, fptr);
|
fwrite(dst_buf, 1, img.len * 3, fptr);
|
||||||
}
|
}
|
||||||
|
printf("test 3");
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
free(dst_buf);
|
free(dst_buf);
|
||||||
printf("Encode Done!\n");
|
printf("Encode Done!\n");
|
||||||
@@ -195,7 +199,7 @@ transcode_to_jpeg(PPM* in, JPEG* out)
|
|||||||
out->width = in->width;
|
out->width = in->width;
|
||||||
out->height = in->height;
|
out->height = in->height;
|
||||||
jpeg_save(dst, out, out->name);
|
jpeg_save(dst, out, out->name);
|
||||||
free(dst);
|
free(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -206,26 +210,26 @@ transcode_to_ppm(JPEG* input, PPM* out)
|
|||||||
out->height = input->height;
|
out->height = input->height;
|
||||||
out->len = out->width * out->height;
|
out->len = out->width * out->height;
|
||||||
ppm_save(dst, *out);
|
ppm_save(dst, *out);
|
||||||
free(dst);
|
free(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
PPM
|
PPM
|
||||||
inherit_from_jpeg(const JPEG* in, const char fmt) {
|
inherit_from_jpeg(const JPEG* in, const char fmt)
|
||||||
PPM image = {
|
{
|
||||||
.width = in->width,
|
PPM image = { .width = in->width,
|
||||||
.height = in->height,
|
.height = in->height,
|
||||||
.len = in->width * in->height,
|
.len = in->width * in->height,
|
||||||
.fmt = fmt
|
.fmt = fmt };
|
||||||
};
|
return image;
|
||||||
return image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPEG
|
JPEG
|
||||||
inherit_from_ppm(const PPM* in) {
|
inherit_from_ppm(const PPM* in)
|
||||||
JPEG image = {
|
{
|
||||||
.width = in->width,
|
JPEG image = {
|
||||||
.height = in->height,
|
.width = in->width,
|
||||||
.len = in->width * in->height,
|
.height = in->height,
|
||||||
};
|
.len = in->width * in->height,
|
||||||
return image;
|
};
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user