Mercurial > hg > dmlib
diff src/libgfx.c @ 902:c6c480e8e1c8
Add separate X and Y scaling to gfxconv and libgfx outputters.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 23 Feb 2015 20:45:31 +0200 |
parents | e7019bd83cca |
children | ebe0d93e03c0 |
line wrap: on
line diff
--- a/src/libgfx.c Mon Feb 23 20:18:34 2015 +0200 +++ b/src/libgfx.c Mon Feb 23 20:45:31 2015 +0200 @@ -134,7 +134,7 @@ Uint8 *row = NULL; // Allocate memory for row buffer - rowWidth = img->width * spec->scale; + rowWidth = img->width * spec->scaleX; rowSize = rowWidth * dmImageGetBytesPerPixel(spec->format); if ((row = dmMalloc(rowSize + 16)) == NULL) @@ -156,7 +156,7 @@ switch (spec->format) { case DM_IFMT_PALETTE: - for (xscale = 0; xscale < spec->scale; xscale++) + for (xscale = 0; xscale < spec->scaleX; xscale++) *ptr1++ = c; break; @@ -166,7 +166,7 @@ qb = img->pal[c].b; qa = img->pal[c].a; - for (xscale = 0; xscale < spec->scale; xscale++) + for (xscale = 0; xscale < spec->scaleX; xscale++) { *ptr1++ = qr; *ptr1++ = qg; @@ -180,7 +180,7 @@ qg = img->pal[c].g; qb = img->pal[c].b; - for (xscale = 0; xscale < spec->scale; xscale++) + for (xscale = 0; xscale < spec->scaleX; xscale++) { *ptr1++ = qr; *ptr1++ = qg; @@ -193,7 +193,7 @@ qg = img->pal[c].g; qb = img->pal[c].b; - for (xscale = 0; xscale < spec->scale; xscale++) + for (xscale = 0; xscale < spec->scaleX; xscale++) { *ptr1++ = qr; *ptr2++ = qg; @@ -203,7 +203,7 @@ } } - for (yscale = 0; yscale < spec->scale; yscale++) + for (yscale = 0; yscale < spec->scaleY; yscale++) { if ((res = writeRowCB(cbdata, row, rowSize)) != DMERR_OK) goto done; @@ -322,8 +322,8 @@ // Write PPM header fprintf(fp, "P6\n%d %d\n255\n", - img->width * spec->scale, - img->height * spec->scale); + img->width * spec->scaleX, + img->height * spec->scaleY); // Write image data spec->format = DM_IFMT_RGB; @@ -413,8 +413,8 @@ } png_set_IHDR(png_ptr, info_ptr, - img->width * spec->scale, - img->height * spec->scale, + img->width * spec->scaleX, + img->height * spec->scaleY, 8, /* bits per component */ fmt, PNG_INTERLACE_NONE, @@ -422,8 +422,8 @@ PNG_FILTER_TYPE_DEFAULT); dmMsg(3, "PNG: %d x %d, depth=%d, type=%d\n", - img->width * spec->scale, - img->height * spec->scale, + img->width * spec->scaleX, + img->height * spec->scaleY, 8, fmt); // Palette @@ -820,15 +820,15 @@ hdr.version = 5; hdr.encoding = 1; hdr.bpp = 8; - hdr.hres = img->width * spec->scale; - hdr.vres = img->height * spec->scale; + hdr.hres = img->width * spec->scaleX; + hdr.vres = img->height * spec->scaleY; hdr.xmin = hdr.ymin = 0; hdr.xmax = hdr.hres - 1; hdr.ymax = hdr.vres - 1; hdr.nplanes = dmImageGetBytesPerPixel(pcx.format); hdr.palinfo = 1; - res = (img->width * spec->scale); + res = (img->width * spec->scaleX); hdr.bpl = res / 2; if (res % 2) hdr.bpl++; hdr.bpl *= 2;