Assume unpremultiplied input in all cases. Reformat.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@14335 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2002-08-26 14:36:43 +00:00
parent a35bc00d50
commit a008e3d919
2 changed files with 347 additions and 327 deletions

View file

@ -1,3 +1,9 @@
2002-08-26 16:36 Alexander Malmberg <alexander@malmberg.org>
* Source/art/image.m: Assume that input isn't premultiplied in
all cases (to match -xlib behavior, for now). Reformat to fit
coding standards better.
2002-08-26 15:59 Alexander Malmberg <alexander@malmberg.org> 2002-08-26 15:59 Alexander Malmberg <alexander@malmberg.org>
* Headers/art/ARTContext.h, Source/art/ARTContext.m, * Headers/art/ARTContext.h, Source/art/ARTContext.m,

View file

@ -33,7 +33,8 @@ Image drawing. DPSimage and helpers.
#include "blit.h" #include "blit.h"
static unsigned int _get_8_bits(const unsigned char *ptr,int bit_ofs,int num_bits) static unsigned int _get_8_bits(const unsigned char *ptr, int bit_ofs,
int num_bits)
{ {
/* /*
TODO: if we get values with more than 8 bits, we should round properly and TODO: if we get values with more than 8 bits, we should round properly and
@ -57,6 +58,7 @@ not just discard the extra bits
bit_ofs = 0; bit_ofs = 0;
} }
} }
/* extend what we've got to 8 bits */
switch (num_bits) switch (num_bits)
{ {
case 1: case 1:
@ -103,7 +105,8 @@ typedef struct
} image_info_t; } image_info_t;
static void _image_get_color_rgb_8(image_info_t *ii,render_run_t *ri,int x,int y) static void _image_get_color_rgb_8(image_info_t *ii, render_run_t *ri,
int x, int y)
{ {
int ofs; int ofs;
@ -135,7 +138,8 @@ static void _image_get_color_rgb_8(image_info_t *ii,render_run_t *ri,int x,int y
} }
} }
static void _image_get_color_rgb_cmyk_gray(image_info_t *ii,render_run_t *ri,int x,int y) static void _image_get_color_rgb_cmyk_gray(image_info_t *ii, render_run_t *ri,
int x, int y)
{ {
int ofs, bit_ofs; int ofs, bit_ofs;
int values[5]; int values[5];
@ -186,7 +190,8 @@ static void _image_get_color_rgb_cmyk_gray(image_info_t *ii,render_run_t *ri,int
@implementation ARTGState (image) @implementation ARTGState (image)
-(void) _image_do_rgb_transform: (image_info_t *)ii : (NSAffineTransform *)matrix -(void) _image_do_rgb_transform: (image_info_t *)ii
: (NSAffineTransform *)matrix
: (void (*)(image_info_t *ii, render_run_t *ri, int x, int y))ifunc : (void (*)(image_info_t *ii, render_run_t *ri, int x, int y))ifunc
{ {
/* /*
@ -375,11 +380,13 @@ seem to cause edges to be off by a pixel
ty_frac = lty_frac * de * r_de; ty_frac = lty_frac * de * r_de;
de *= r_de * l_de; de *= r_de * l_de;
delta=(rtx*r_de+rtx_frac)*l_de-(ltx*l_de+ltx_frac)*r_de; delta = (rtx * r_de + rtx_frac) * l_de
- (ltx * l_de + ltx_frac) * r_de;
dtx = delta / de; dtx = delta / de;
dtx_frac = delta % de; dtx_frac = delta % de;
delta=(rty*r_de+rty_frac)*l_de-(lty*l_de+lty_frac)*r_de; delta = (rty * r_de + rty_frac) * l_de
- (lty * l_de + lty_frac) * r_de;
dty = delta / de; dty = delta / de;
dty_frac = delta % de; dty_frac = delta % de;
@ -406,7 +413,8 @@ seem to cause edges to be off by a pixel
} }
if (x1 >= clip_x1) x1 = clip_x1 - 1; if (x1 >= clip_x1) x1 = clip_x1 - 1;
ri.dst=wi->data+x0*DI.bytes_per_pixel+cy*wi->bytes_per_line; ri.dst = wi->data + x0 * DI.bytes_per_pixel
+ cy * wi->bytes_per_line;
ri.dsta = wi->alpha + x0 + cy * wi->sx; ri.dsta = wi->alpha + x0 + cy * wi->sx;
if (wi->has_alpha) if (wi->has_alpha)
@ -472,8 +480,10 @@ seem to cause edges to be off by a pixel
if (all_clipped) return; if (all_clipped) return;
[matrix prependTransform: ctm]; [matrix prependTransform: ctm];
if (fabs(matrix->matrix.m11-1.0)<0.001 && fabs(matrix->matrix.m12)<0.001 && if (fabs(matrix->matrix.m11 - 1.0) < 0.001 &&
fabs(matrix->matrix.m22-1.0)<0.001 && fabs(matrix->matrix.m21)<0.001) fabs(matrix->matrix.m12) < 0.001 &&
fabs(matrix->matrix.m22 - 1.0) < 0.001 &&
fabs(matrix->matrix.m21) < 0.001)
identity_transform = YES; identity_transform = YES;
else else
identity_transform = NO; identity_transform = NO;
@ -486,7 +496,8 @@ seem to cause edges to be off by a pixel
/* optimize common case */ /* optimize common case */
if (identity_transform && is_rgb && if (identity_transform && is_rgb &&
bitsPerSample==8 && !isPlanar && bytesPerRow==samplesPerPixel*pixelsWide && bitsPerSample == 8 && !isPlanar &&
bytesPerRow == samplesPerPixel * pixelsWide &&
((samplesPerPixel == 3 && bitsPerPixel == 24 && !hasAlpha) || ((samplesPerPixel == 3 && bitsPerPixel == 24 && !hasAlpha) ||
(samplesPerPixel == 4 && bitsPerPixel == 32 && hasAlpha))) (samplesPerPixel == 4 && bitsPerPixel == 32 && hasAlpha)))
{ {
@ -512,7 +523,8 @@ seem to cause edges to be off by a pixel
{ {
for (x = 0; x < pixelsWide; x++) for (x = 0; x < pixelsWide; x++)
{ {
if (x+ox<clip_x0 || x+ox>=clip_x1 || y+oy<clip_y0 || y+oy>=clip_y1) if (x + ox < clip_x0 || x + ox >= clip_x1 ||
y + oy < clip_y0 || y + oy >= clip_y1)
{ {
if (hasAlpha) if (hasAlpha)
src += 4; src += 4;
@ -520,7 +532,8 @@ seem to cause edges to be off by a pixel
src += 3; src += 3;
continue; continue;
} }
ri.dst=wi->data+(x+ox)*DI.bytes_per_pixel+(y+oy)*wi->bytes_per_line; ri.dst = wi->data + (x + ox) * DI.bytes_per_pixel
+ (y + oy) * wi->bytes_per_line;
ri.dsta = wi->alpha + (x + ox) + (y + oy) * wi->sx; ri.dsta = wi->alpha + (x + ox) + (y + oy) * wi->sx;
ri.r = src[0]; ri.r = src[0];
ri.g = src[1]; ri.g = src[1];
@ -529,12 +542,12 @@ seem to cause edges to be off by a pixel
{ {
ri.a = src[3]; ri.a = src[3];
/* TODO: find out if input is premultiplied or not */ /* TODO: find out if input is premultiplied or not */
if (ri.a && ri.a!=255) /* if (ri.a && ri.a != 255)
{ {
ri.r = (255 * ri.r) / ri.a; ri.r = (255 * ri.r) / ri.a;
ri.g = (255 * ri.g) / ri.a; ri.g = (255 * ri.g) / ri.a;
ri.b = (255 * ri.b) / ri.a; ri.b = (255 * ri.b) / ri.a;
} }*/
if (alpha_dest) if (alpha_dest)
{ {
if (src[3] == 255) if (src[3] == 255)
@ -597,7 +610,8 @@ seem to cause edges to be off by a pixel
if (ii.colorspace != 0) if (ii.colorspace != 0)
{ {
[self _image_do_rgb_transform: &ii : matrix : _image_get_color_rgb_cmyk_gray]; [self _image_do_rgb_transform: &ii : matrix :
_image_get_color_rgb_cmyk_gray];
return; return;
} }