mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
For cairo convert the bitmap, when the format is unsupported.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@27014 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ad0a88c152
commit
01b5c75e8f
2 changed files with 62 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2008-11-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/cairo/CairoContext.m (-GSDrawImage::): Convert the
|
||||||
|
bitmap, when the format is unsupported.
|
||||||
|
|
||||||
2008-10-26 Fred Kiefer <FredKiefer@gmx.de>
|
2008-10-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/x11/XWindowBuffer.m (test_xshm): Check whether the X
|
* Source/x11/XWindowBuffer.m (test_xshm): Check whether the X
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AppKit/NSBitmapImageRep.h>
|
||||||
|
#include <AppKit/NSGraphics.h>
|
||||||
|
|
||||||
#include "cairo/CairoContext.h"
|
#include "cairo/CairoContext.h"
|
||||||
#include "cairo/CairoGState.h"
|
#include "cairo/CairoGState.h"
|
||||||
#include "cairo/CairoSurface.h"
|
#include "cairo/CairoSurface.h"
|
||||||
|
@ -62,6 +65,16 @@
|
||||||
# error Invalid server for Cairo backend : non implemented
|
# error Invalid server for Cairo backend : non implemented
|
||||||
#endif /* BUILD_SERVER */
|
#endif /* BUILD_SERVER */
|
||||||
|
|
||||||
|
@interface NSBitmapImageRep (GSPrivate)
|
||||||
|
- (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
|
||||||
|
|
||||||
@implementation CairoContext
|
@implementation CairoContext
|
||||||
|
|
||||||
|
@ -118,6 +131,50 @@
|
||||||
|
|
||||||
@implementation CairoContext (Ops)
|
@implementation CairoContext (Ops)
|
||||||
|
|
||||||
|
- (void) GSDrawImage: (NSRect)rect: (void *)imageref
|
||||||
|
{
|
||||||
|
NSBitmapImageRep *bitmap;
|
||||||
|
const unsigned char *data[5];
|
||||||
|
NSString *colorSpaceName;
|
||||||
|
|
||||||
|
bitmap = (NSBitmapImageRep*)imageref;
|
||||||
|
colorSpaceName = [bitmap colorSpaceName];
|
||||||
|
if ([bitmap isPlanar] || ([bitmap bitmapFormat] != 0)
|
||||||
|
|| ([bitmap bitsPerPixel] != 8) ||
|
||||||
|
(![colorSpaceName isEqualToString: NSDeviceRGBColorSpace] &&
|
||||||
|
![colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]))
|
||||||
|
{
|
||||||
|
int bitsPerSample = 8;
|
||||||
|
BOOL isPlanar = NO;
|
||||||
|
int samplesPerPixel = [bitmap hasAlpha] ? 4 : 3;
|
||||||
|
NSString *colorSpaceName = NSCalibratedRGBColorSpace;
|
||||||
|
NSBitmapImageRep *new;
|
||||||
|
|
||||||
|
new = [bitmap _convertToFormatBitsPerSample: bitsPerSample
|
||||||
|
samplesPerPixel: samplesPerPixel
|
||||||
|
hasAlpha: [bitmap hasAlpha]
|
||||||
|
isPlanar: isPlanar
|
||||||
|
colorSpaceName: colorSpaceName
|
||||||
|
bitmapFormat: 0
|
||||||
|
bytesPerRow: 0
|
||||||
|
bitsPerPixel: 0];
|
||||||
|
|
||||||
|
if (new == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"Could not convert bitmap data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bitmap = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
[bitmap getBitmapDataPlanes: (unsigned char **)&data];
|
||||||
|
[self NSDrawBitmap: rect : [bitmap pixelsWide] : [bitmap pixelsHigh]
|
||||||
|
: [bitmap bitsPerSample] : [bitmap samplesPerPixel]
|
||||||
|
: [bitmap bitsPerPixel] : [bitmap bytesPerRow] : [bitmap isPlanar]
|
||||||
|
: [bitmap hasAlpha] : [bitmap colorSpaceName]
|
||||||
|
: data];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y
|
- (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y
|
||||||
{
|
{
|
||||||
CairoSurface *surface;
|
CairoSurface *surface;
|
||||||
|
|
Loading…
Reference in a new issue