mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +00:00
Small improvements on premultiplcation of alpha.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26276 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7994cd4519
commit
eb32df9161
2 changed files with 39 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-03-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSBitmapImageRep.m (-_premultiply, _unpremultiply):
|
||||||
|
Optimized a bit.
|
||||||
|
* Source/NSBitmapImageRep.m (-draw): Premultiply the image before
|
||||||
|
drawing.
|
||||||
|
|
||||||
2008-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
2008-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSToolbarItem.m (-_setSelected:):
|
* Source/NSToolbarItem.m (-_setSelected:):
|
||||||
|
|
|
@ -65,6 +65,16 @@
|
||||||
// Internal
|
// Internal
|
||||||
+ (int) _localFromCompressionType: (NSTIFFCompression)type;
|
+ (int) _localFromCompressionType: (NSTIFFCompression)type;
|
||||||
+ (NSTIFFCompression) _compressionTypeFromLocal: (int)type;
|
+ (NSTIFFCompression) _compressionTypeFromLocal: (int)type;
|
||||||
|
- (void) _premultiply;
|
||||||
|
- (void) _unpremultiply;
|
||||||
|
- (NSBitmapImageRep *) _convertToFormatBitsPerSample: (int)bps
|
||||||
|
samplesPerPixel: (int)spp
|
||||||
|
hasAlpha: (BOOL)alpha
|
||||||
|
isPlanar: (BOOL)isPlanar
|
||||||
|
colorSpaceName: (NSString*)colorSpaceName
|
||||||
|
bitmapFormat: (NSBitmapFormat)bitmapFormat
|
||||||
|
bytesPerRow: (int)rowBytes
|
||||||
|
bitsPerPixel: (int)pixelBits;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -553,6 +563,7 @@
|
||||||
[self setOpaque: YES];
|
[self setOpaque: YES];
|
||||||
}
|
}
|
||||||
_properties = [[NSMutableDictionary alloc] init];
|
_properties = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,6 +1361,7 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
||||||
NSRect irect = NSMakeRect(0, 0, _size.width, _size.height);
|
NSRect irect = NSMakeRect(0, 0, _size.width, _size.height);
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||||
|
|
||||||
|
[self _premultiply];
|
||||||
[ctxt GSDrawImage: irect : self];
|
[ctxt GSDrawImage: irect : self];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -1934,14 +1946,17 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
||||||
//[self getPixel: pixelData atX: x y: y];
|
//[self getPixel: pixelData atX: x y: y];
|
||||||
getP(self, getPSel, pixelData, x, y);
|
getP(self, getPSel, pixelData, x, y);
|
||||||
a = pixelData[ai];
|
a = pixelData[ai];
|
||||||
for (i = start; i < end; i++)
|
if (a != 255)
|
||||||
{
|
{
|
||||||
unsigned int t = a * pixelData[i] + 0x80;
|
for (i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
unsigned int t = a * pixelData[i] + 0x80;
|
||||||
|
|
||||||
pixelData[i] = ((t >> 8) + t) >> 8;
|
pixelData[i] = ((t >> 8) + t) >> 8;
|
||||||
|
}
|
||||||
|
//[self setPixel: pixelData atX: x y: y];
|
||||||
|
setP(self, setPSel, pixelData, x, y);
|
||||||
}
|
}
|
||||||
//[self setPixel: pixelData atX: x y: y];
|
|
||||||
setP(self, setPSel, pixelData, x, y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2008,11 +2023,21 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
||||||
//[self getPixel: pixelData atX: x y: y];
|
//[self getPixel: pixelData atX: x y: y];
|
||||||
getP(self, getPSel, pixelData, x, y);
|
getP(self, getPSel, pixelData, x, y);
|
||||||
a = pixelData[ai];
|
a = pixelData[ai];
|
||||||
if (a != 0)
|
if ((a != 0) && (a != 255))
|
||||||
{
|
{
|
||||||
for (i = start; i < end; i++)
|
for (i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
pixelData[i] = (pixelData[i] * 255) / a;
|
unsigned int c;
|
||||||
|
|
||||||
|
c = (pixelData[i] * 255) / a;
|
||||||
|
if (c >= 255)
|
||||||
|
{
|
||||||
|
pixelData[i] = 255;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pixelData[i] = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//[self setPixel: pixelData atX: x y: y];
|
//[self setPixel: pixelData atX: x y: y];
|
||||||
setP(self, setPSel, pixelData, x, y);
|
setP(self, setPSel, pixelData, x, y);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue