+#include <stdlib.h>
#include <math.h>
#include <memory.h>
#include "jpeg.h"
#include "gfximage.h"
#include "types.h"
+gfximage_t*gfximage_new(int width, int height)
+{
+ gfximage_t*i = rfx_calloc(sizeof(gfximage_t));
+ i->data = rfx_calloc(width*height*4);
+ i->width = width;
+ i->height = height;
+ return i;
+}
+
void gfximage_save_jpeg(gfximage_t*img, const char*filename, int quality)
{
int x,y;
data[s+2] = img->data[t].b;
}
jpeg_save(data, img->width, img->height, quality, filename);
+ free(data);
}
void gfximage_save_png(gfximage_t*image, const char*filename)
for(y=0;y<height;y++) {
gfxcolor_t*s = &src[y*width];
gfxcolor_t*d = &tmp[y*width];
- for(x=0;x<range;x++) {
+ for(x=0;x<range && x<width;x++) {
d[x] = s[x];
}
- for(x=range;x<width-range;x++) {
+ for(;x<width-range;x++) {
int r=0;
int g=0;
int b=0;
d[x].b = b >> 16;
d[x].a = a >> 16;
}
- for(x=width-range;x<width;x++) {
+ for(;x<width;x++) {
d[x] = s[x];
}
}
gfxcolor_t*s = &tmp[x];
gfxcolor_t*d = &src[x];
int yy=0;
- for(y=0;y<range;y++) {
+ for(y=0;y<range&&y<height;y++) {
d[yy] = s[yy];
yy+=width;
}
- for(y=range;y<height-range;y++) {
+ for(;y<height-range;y++) {
int r=0;
int g=0;
int b=0;
d[yy].a = a >> 16;
yy += width;
}
- for(y=0;y<range;y++) {
+ for(;y<height;y++) {
d[yy] = s[yy];
yy += width;
}
rgba_int_t*tmpline;
int monochrome = 0;
gfxcolor_t monochrome_colors[2];
-
- if(newwidth<1 || newheight<1)
- return 0;
+
+ if(newwidth<1)
+ newwidth=1;
+ if(newheight<1)
+ newheight=1;
int width = image->width;
int height = image->height;
image2->height = newheight;
return image2;
}
+
+void gfximage_free(gfximage_t*b)
+{
+ free(b->data);
+ b->data = 0;
+ free(b);
+}
+