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:
Adam Fedor 1999-12-28 19:20:45 +00:00
parent 5733733fee
commit 4f1dbcfbe8
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>
Initial hack of support for encoding/decoding images - untested.

View file

@ -484,6 +484,14 @@ static inline void
DPSimagemask(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPScolorimage(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSalphaimage(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSkshow(GSCTXT *ctxt, const char *s)
__attribute__((unused));
@ -1700,6 +1708,20 @@ DPSimagemask(GSCTXT *ctxt)
(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
DPSkshow(GSCTXT *ctxt, const char *s)
{

View file

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

View file

@ -287,6 +287,8 @@ NSGraphicsContext *GSCurrentContext();
- (void) DPSfill;
- (void) DPSimage;
- (void) DPSimagemask;
- (void) DPScolorimage;
- (void) DPSalphaimage;
- (void) DPSkshow: (const char *)s ;
- (void) DPSrectfill: (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()
__attribute__((unused));
static inline void
PScolorimage()
__attribute__((unused));
static inline void
PSalphaimage()
__attribute__((unused));
static inline void
PSkshow(const char *s)
__attribute__((unused));
@ -1406,6 +1414,18 @@ PSimagemask()
DPSimagemask(DEFCTXT);
}
static inline void
PScolorimage()
{
DPScolorimage(DEFCTXT);
}
static inline void
PSalphaimage()
{
DPSalphaimage(DEFCTXT);
}
static inline void
PSkshow(const char *s)
{

View file

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

View file

@ -353,7 +353,18 @@
- (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 <Foundation/NSString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSCachedImageRep.h>
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
#include <AppKit/PSOperators.h>
static BOOL NSImageCompositing = NO;
@interface GSCacheW : NSWindow
@end
@ -69,6 +73,12 @@
@implementation NSCachedImageRep
- (void) initialize
{
NSImageCompositing = [[NSUserDefaults standardUserDefaults]
boolForKey: @"ImageCompositing"];
}
// Initializing an NSCachedImageRep
- (id) initWithSize: (NSSize)aSize
depth: (NSWindowDepth)aDepth
@ -142,8 +152,13 @@
- (BOOL)draw
{
NSCopyBits([_window gState], _rect, _rect.origin);
return NO;
if (NSImageCompositing)
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
@ -160,7 +175,12 @@
if ([[ctxt focusView] isFlipped])
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;
}
@ -176,8 +196,13 @@
ctxt = GSCurrentContext();
if ([[ctxt focusView] isFlipped])
aRect.origin.y -= NSHeight(aRect);
NSCopyBits([_window gState], _rect, aRect.origin);
return NO;
if (NSImageCompositing)
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

View file

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

View file

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

View file

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

View file

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