More imaging and compositing stuff

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5635 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1999-12-28 19:20:45 +00:00
parent 0d72b6f34d
commit 745d515d38
12 changed files with 142 additions and 21 deletions

View file

@ -1,3 +1,15 @@
1999-12-28 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/gui/DPSOperators.h: New operators colorimage
and alphaimage.
* Headers/gnustep/gui/NSGraphicsContext.h: Likewise.
* Source/NSGraphicsContex.m: Add stubs.
* Source/NSBitmapImageRep.m (-draw): Implement using NSDrawBitmap.
* Source/NSCachedImageRep.m: Conditional use of PScomposite functions
for drawing methods (set user default "ImageCompositing" to YES
for this to work).
Tue Dec 28 15:58:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Tue Dec 28 15:58:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
Initial hack of support for encoding/decoding images - untested. Initial hack of support for encoding/decoding images - untested.

View file

@ -484,6 +484,14 @@ static inline void
DPSimagemask(GSCTXT *ctxt) DPSimagemask(GSCTXT *ctxt)
__attribute__((unused)); __attribute__((unused));
static inline void
DPScolorimage(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSalphaimage(GSCTXT *ctxt)
__attribute__((unused));
static inline void static inline void
DPSkshow(GSCTXT *ctxt, const char *s) DPSkshow(GSCTXT *ctxt, const char *s)
__attribute__((unused)); __attribute__((unused));
@ -1700,6 +1708,20 @@ DPSimagemask(GSCTXT *ctxt)
(ctxt, @selector(DPSimagemask)); (ctxt, @selector(DPSimagemask));
} }
static inline void
DPScolorimage(GSCTXT *ctxt)
{
(ctxt->methods->DPScolorimage)
(ctxt, @selector(DPScolorimage));
}
static inline void
DPSalphaimage(GSCTXT *ctxt)
{
(ctxt->methods->DPSalphaimage)
(ctxt, @selector(DPSalphaimage));
}
static inline void static inline void
DPSkshow(GSCTXT *ctxt, const char *s) DPSkshow(GSCTXT *ctxt, const char *s)
{ {

View file

@ -273,6 +273,10 @@ typedef struct {
(NSGraphicsContext*, SEL); (NSGraphicsContext*, SEL);
void (*DPSimagemask) void (*DPSimagemask)
(NSGraphicsContext*, SEL); (NSGraphicsContext*, SEL);
void (*DPScolorimage)
(NSGraphicsContext*, SEL);
void (*DPSalphaimage)
(NSGraphicsContext*, SEL);
void (*DPSkshow_) void (*DPSkshow_)
(NSGraphicsContext*, SEL, const char*); (NSGraphicsContext*, SEL, const char*);
void (*DPSrectfill____) void (*DPSrectfill____)

View file

@ -287,6 +287,8 @@ NSGraphicsContext *GSCurrentContext();
- (void) DPSfill; - (void) DPSfill;
- (void) DPSimage; - (void) DPSimage;
- (void) DPSimagemask; - (void) DPSimagemask;
- (void) DPScolorimage;
- (void) DPSalphaimage;
- (void) DPSkshow: (const char *)s ; - (void) DPSkshow: (const char *)s ;
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h ; - (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h ;
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h ; - (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h ;

View file

@ -488,6 +488,14 @@ static inline void
PSimagemask() PSimagemask()
__attribute__((unused)); __attribute__((unused));
static inline void
PScolorimage()
__attribute__((unused));
static inline void
PSalphaimage()
__attribute__((unused));
static inline void static inline void
PSkshow(const char *s) PSkshow(const char *s)
__attribute__((unused)); __attribute__((unused));
@ -1406,6 +1414,18 @@ PSimagemask()
DPSimagemask(DEFCTXT); DPSimagemask(DEFCTXT);
} }
static inline void
PScolorimage()
{
DPScolorimage(DEFCTXT);
}
static inline void
PSalphaimage()
{
DPSalphaimage(DEFCTXT);
}
static inline void static inline void
PSkshow(const char *s) PSkshow(const char *s)
{ {

View file

@ -48,6 +48,7 @@ typedef struct {
u_short planarConfig; /* meshed or separate */ u_short planarConfig; /* meshed or separate */
u_short photoInterp; /* photometric interpretation of bitmap data, */ u_short photoInterp; /* photometric interpretation of bitmap data, */
u_short compression; u_short compression;
u_short extraSamples; /* Alpha */
int quality; /* compression quality (for jpeg) 1 to 255 */ int quality; /* compression quality (for jpeg) 1 to 255 */
int numImages; /* number of images in tiff */ int numImages; /* number of images in tiff */
int error; int error;

View file

@ -353,7 +353,18 @@
- (BOOL) draw - (BOOL) draw
{ {
return NO; NSDrawBitmap(NSZeroRect,
_pixelsWide,
_pixelsHigh,
bitsPerSample,
numColors,
bitsPerPixel,
bytesPerRow,
_isPlanar,
hasAlpha,
_colorSpace,
imagePlanes);
return YES;
} }
// //

View file

@ -34,10 +34,14 @@
#include <gnustep/gui/config.h> #include <gnustep/gui/config.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSCachedImageRep.h> #include <AppKit/NSCachedImageRep.h>
#include <AppKit/NSView.h> #include <AppKit/NSView.h>
#include <AppKit/NSWindow.h> #include <AppKit/NSWindow.h>
#include <AppKit/PSOperators.h>
static BOOL NSImageCompositing = NO;
@interface GSCacheW : NSWindow @interface GSCacheW : NSWindow
@end @end
@ -69,6 +73,12 @@
@implementation NSCachedImageRep @implementation NSCachedImageRep
- (void) initialize
{
NSImageCompositing = [[NSUserDefaults standardUserDefaults]
boolForKey: @"ImageCompositing"];
}
// Initializing an NSCachedImageRep // Initializing an NSCachedImageRep
- (id) initWithSize: (NSSize)aSize - (id) initWithSize: (NSSize)aSize
depth: (NSWindowDepth)aDepth depth: (NSWindowDepth)aDepth
@ -142,8 +152,13 @@
- (BOOL)draw - (BOOL)draw
{ {
NSCopyBits([_window gState], _rect, _rect.origin); if (NSImageCompositing)
return NO; PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect),
[_window gState], NSMinX(_rect), NSMinY(_rect),
NSCompositeSourceOver);
else
NSCopyBits([_window gState], _rect, _rect.origin);
return YES;
} }
- (BOOL) drawAtPoint: (NSPoint)aPoint - (BOOL) drawAtPoint: (NSPoint)aPoint
@ -160,7 +175,12 @@
if ([[ctxt focusView] isFlipped]) if ([[ctxt focusView] isFlipped])
aPoint.y -= size.height; aPoint.y -= size.height;
} }
NSCopyBits([_window gState], _rect, aPoint); if (NSImageCompositing)
PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect),
[_window gState], aPoint.x, aPoint.y,
NSCompositeSourceOver);
else
NSCopyBits([_window gState], _rect, aPoint);
return NO; return NO;
} }
@ -176,8 +196,13 @@
ctxt = GSCurrentContext(); ctxt = GSCurrentContext();
if ([[ctxt focusView] isFlipped]) if ([[ctxt focusView] isFlipped])
aRect.origin.y -= NSHeight(aRect); aRect.origin.y -= NSHeight(aRect);
NSCopyBits([_window gState], _rect, aRect.origin); if (NSImageCompositing)
return NO; PScomposite(NSMinX(_rect), NSMinY(_rect), NSWidth(_rect), NSHeight(_rect),
[_window gState], NSMinX(aRect), NSMinY(aRect),
NSCompositeSourceOver);
else
NSCopyBits([_window gState], _rect, aRect.origin);
return YES;
} }
// NSCoding protocol // NSCoding protocol

View file

@ -587,6 +587,10 @@ NSGraphicsContext *GSCurrentContext()
GET_IMP(@selector(DPSimage)); GET_IMP(@selector(DPSimage));
methodTable.DPSimagemask = methodTable.DPSimagemask =
GET_IMP(@selector(DPSimagemask)); GET_IMP(@selector(DPSimagemask));
methodTable.DPScolorimage =
GET_IMP(@selector(DPScolorimage));
methodTable.DPSalphaimage =
GET_IMP(@selector(DPSalphaimage));
methodTable.DPSkshow_ = methodTable.DPSkshow_ =
GET_IMP(@selector(DPSkshow:)); GET_IMP(@selector(DPSkshow:));
methodTable.DPSrectfill____ = methodTable.DPSrectfill____ =
@ -1419,6 +1423,16 @@ NSGraphicsContext *GSCurrentContext()
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
- (void) DPScolorimage
{
[self subclassResponsibility: _cmd];
}
- (void) DPSalphaimage
{
[self subclassResponsibility: _cmd];
}
- (void) DPSkshow: (const char *)s - (void) DPSkshow: (const char *)s
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];

View file

@ -32,6 +32,7 @@
#include <Foundation/NSData.h> #include <Foundation/NSData.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSImageRep.h> #include <AppKit/NSImageRep.h>
#include <AppKit/NSBitmapImageRep.h> #include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSEPSImageRep.h> #include <AppKit/NSEPSImageRep.h>
@ -51,7 +52,9 @@ static NSMutableArray* imageReps = NULL;
if (self == [NSImageRep class]) if (self == [NSImageRep class])
{ {
imageReps = [[NSMutableArray alloc] initWithCapacity: 2]; imageReps = [[NSMutableArray alloc] initWithCapacity: 2];
// [imageReps addObject: [NSBitmapImageRep class]]; if ([[NSUserDefaults standardUserDefaults]
boolForKey: @"ImageCompositing"])
[imageReps addObject: [NSBitmapImageRep class]];
// [imageReps addObject: [NSEPSImageRep class]]; // [imageReps addObject: [NSEPSImageRep class]];
} }
} }

View file

@ -109,10 +109,17 @@ static NSScreen *mainScreen = nil;
else else
device_desc = [[NSMutableDictionary dictionary] retain]; device_desc = [[NSMutableDictionary dictionary] retain];
if (ctxt == nil)
{
NSLog(@"Internal error: No current context\n");
[self release];
return nil;
}
if ([ctxt isDrawingToScreen] == NO) if ([ctxt isDrawingToScreen] == NO)
{ {
NSLog(@"Internal error: trying to find screen with wrong context\n"); NSLog(@"Internal error: trying to find screen with wrong context\n");
[self dealloc]; [self release];
return nil; return nil;
} }

View file

@ -84,7 +84,7 @@ static tsize_t
TiffHandleRead(thandle_t handle, tdata_t buf, toff_t count) TiffHandleRead(thandle_t handle, tdata_t buf, toff_t count)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleRead\n"); NSDebugLLog(@"NSImage", @"TiffHandleRead\n");
if (chand->position >= chand->size) if (chand->position >= chand->size)
return 0; return 0;
if (chand->position + count > chand->size) if (chand->position + count > chand->size)
@ -97,7 +97,7 @@ static tsize_t
TiffHandleWrite(thandle_t handle, tdata_t buf, toff_t count) TiffHandleWrite(thandle_t handle, tdata_t buf, toff_t count)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleWrite\n"); NSDebugLLog(@"NSImage", @"TiffHandleWrite\n");
if (chand->mode == "r") if (chand->mode == "r")
return 0; return 0;
if (chand->position + count > chand->size) if (chand->position + count > chand->size)
@ -120,7 +120,7 @@ static toff_t
TiffHandleSeek(thandle_t handle, toff_t offset, int mode) TiffHandleSeek(thandle_t handle, toff_t offset, int mode)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleSeek\n"); NSDebugLLog(@"NSImage", @"TiffHandleSeek\n");
switch(mode) switch(mode)
{ {
case SEEK_SET: chand->position = offset; break; case SEEK_SET: chand->position = offset; break;
@ -139,7 +139,7 @@ TiffHandleClose(thandle_t handle)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleClose\n"); NSDebugLLog(@"NSImage", @"TiffHandleClose\n");
/* Presumably, we don't need the handle anymore */ /* Presumably, we don't need the handle anymore */
OBJC_FREE(chand); OBJC_FREE(chand);
return 0; return 0;
@ -149,7 +149,7 @@ static toff_t
TiffHandleSize(thandle_t handle) TiffHandleSize(thandle_t handle)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleSize\n"); NSDebugLLog(@"NSImage", @"TiffHandleSize\n");
return chand->size; return chand->size;
} }
@ -158,7 +158,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
{ {
chandle_t* chand = (chandle_t *)handle; chandle_t* chand = (chandle_t *)handle;
NSDebugLog (@"TiffHandleMap\n"); NSDebugLLog(@"NSImage", @"TiffHandleMap\n");
*data = chand->data; *data = chand->data;
*size = chand->size; *size = chand->size;
@ -168,7 +168,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
static void static void
TiffHandleUnmap(thandle_t handle, tdata_t data, toff_t size) TiffHandleUnmap(thandle_t handle, tdata_t data, toff_t size)
{ {
NSDebugLog (@"TiffHandleUnmap\n"); NSDebugLLog(@"NSImage", @"TiffHandleUnmap\n");
/* Nothing to unmap. */ /* Nothing to unmap. */
} }
@ -177,7 +177,7 @@ TIFF*
NSTiffOpenDataRead(const char* data, long size) NSTiffOpenDataRead(const char* data, long size)
{ {
chandle_t* handle; chandle_t* handle;
NSDebugLog (@"NSTiffOpenData\n"); NSDebugLLog(@"NSImage", @"NSTiffOpenData\n");
OBJC_MALLOC(handle, chandle_t, 1); OBJC_MALLOC(handle, chandle_t, 1);
handle->data = (char*)data; handle->data = (char*)data;
handle->outdata = 0; handle->outdata = 0;
@ -197,7 +197,7 @@ TIFF*
NSTiffOpenDataWrite(char **data, long *size) NSTiffOpenDataWrite(char **data, long *size)
{ {
chandle_t* handle; chandle_t* handle;
NSDebugLog (@"NSTiffOpenData\n"); NSDebugLLog(@"NSImage", @"NSTiffOpenData\n");
OBJC_MALLOC(handle, chandle_t, 1); OBJC_MALLOC(handle, chandle_t, 1);
handle->data = *data; handle->data = *data;
handle->outdata = data; handle->outdata = data;
@ -378,7 +378,7 @@ NSTiffRead(int imageNumber, TIFF* image, NSTiffInfo* info, char* data)
case PHOTOMETRIC_RGB: case PHOTOMETRIC_RGB:
if (newinfo->planarConfig == PLANARCONFIG_CONTIG) if (newinfo->planarConfig == PLANARCONFIG_CONTIG)
{ {
NSDebugLog(@"PHOTOMETRIC_RGB: CONTIG\n"); NSDebugLLog(@"NSImage", @"PHOTOMETRIC_RGB: CONTIG\n");
for (row = 0; row < newinfo->height; ++row) for (row = 0; row < newinfo->height; ++row)
{ {
READ_SCANLINE(0) READ_SCANLINE(0)
@ -391,7 +391,7 @@ NSTiffRead(int imageNumber, TIFF* image, NSTiffInfo* info, char* data)
} }
else else
{ {
NSDebugLog(@"PHOTOMETRIC_RGB: NOT CONTIG\n"); NSDebugLLog(@"NSImage", @"PHOTOMETRIC_RGB: NOT CONTIG\n");
for (i = 0; i < newinfo->samplesPerPixel; i++) for (i = 0; i < newinfo->samplesPerPixel; i++)
for (row = 0; row < newinfo->height; ++row) for (row = 0; row < newinfo->height; ++row)
{ {
@ -470,7 +470,7 @@ NSWriteTiff(TIFF* image, NSTiffInfo* info, char* data)
case PHOTOMETRIC_RGB: case PHOTOMETRIC_RGB:
if (info->planarConfig == PLANARCONFIG_CONTIG) if (info->planarConfig == PLANARCONFIG_CONTIG)
{ {
NSDebugLog(@"PHOTOMETRIC_RGB: CONTIG\n"); NSDebugLLog(@"NSImage", @"PHOTOMETRIC_RGB: CONTIG\n");
for (row = 0; row < info->height; ++row) for (row = 0; row < info->height; ++row)
{ {
WRITE_SCANLINE(0) WRITE_SCANLINE(0)
@ -479,7 +479,7 @@ NSWriteTiff(TIFF* image, NSTiffInfo* info, char* data)
} }
else else
{ {
NSDebugLog(@"PHOTOMETRIC_RGB: NOT CONTIG\n"); NSDebugLLog(@"NSImage", @"PHOTOMETRIC_RGB: NOT CONTIG\n");
for (i = 0; i < info->samplesPerPixel; i++) for (i = 0; i < info->samplesPerPixel; i++)
{ {
for (row = 0; row < info->height; ++row) for (row = 0; row < info->height; ++row)