mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:00:48 +00:00
Minor bug fixes submitted by Adam Fedor.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1745 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
35993213ff
commit
eb9dea80ec
6 changed files with 87 additions and 57 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
||||||
|
Tue Sep 3 15:24:41 1996 Adam Fedor <fedor@pulse.Colorado.edu>
|
||||||
|
|
||||||
|
* NSBitmapImageRep.h: "Hide" instance variable names.
|
||||||
|
* NSImageRep.h: Likewise.
|
||||||
|
* NSBitmapImageRep.m: Change all pertinent methods to use these new
|
||||||
|
names.
|
||||||
|
* NSImageRep.m: Likewise.
|
||||||
|
|
||||||
|
* NSBitmapImageRep.m (-initWithBitmapDataPlanes:...): Alloc
|
||||||
|
planes array and copy pointers into it.
|
||||||
|
(-dealloc]): Don't free image planes.
|
||||||
|
-bitmapData): retain image data. Alloc planes array if not
|
||||||
|
already there. Fix typo.
|
||||||
|
|
||||||
|
* NSImage.m (extension): Get one copy of cString.
|
||||||
|
* NSImageRep.m (extension): Likewise.
|
||||||
|
|
||||||
|
* NSImage.m (-initWithSize:): Fix typo.
|
||||||
|
(iterate_reps_for_types): Use correct indices.
|
||||||
|
|
||||||
|
* NSImageRep.m (+initialize): Perform only if we are
|
||||||
|
NSImageRep class.
|
||||||
|
(-imageRepsWithContentsOfFile:): Comment out non-working code.
|
||||||
|
|
||||||
Tue Sep 3 13:47:52 1996 GNUstep Development <gnustep@ocbi.com>
|
Tue Sep 3 13:47:52 1996 GNUstep Development <gnustep@ocbi.com>
|
||||||
|
|
||||||
Create initial documentation set.
|
Create initial documentation set.
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
unsigned int numColors;
|
unsigned int numColors;
|
||||||
unsigned int bitsPerPixel;
|
unsigned int bitsPerPixel;
|
||||||
unsigned short compression;
|
unsigned short compression;
|
||||||
BOOL isPlanar;
|
BOOL _isPlanar;
|
||||||
BOOL freePlanes;
|
|
||||||
unsigned char** imagePlanes;
|
unsigned char** imagePlanes;
|
||||||
NSMutableData* imageData;
|
NSMutableData* imageData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
NSString* colorSpace;
|
NSString* _colorSpace;
|
||||||
NSSize size;
|
NSSize size;
|
||||||
BOOL hasAlpha;
|
BOOL hasAlpha;
|
||||||
BOOL isOpaque;
|
BOOL isOpaque;
|
||||||
|
|
|
@ -163,18 +163,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is the designated initializer */
|
/* This is the designated initializer */
|
||||||
/* Note: It's unclear whether or not we own the data that is passed
|
/* Note: If data is actaully passed to us in planes, we DO NOT own this
|
||||||
to us here. Since the data is not of type "const", one could assume
|
data and we DO NOT copy it. Just assume that it will always be available.
|
||||||
that we do own it and that it should not be copied. I'm also assuming
|
*/
|
||||||
we own the data that "planes" points to. This is all a very hazardous
|
|
||||||
assumption. It's also harder to deal with. */
|
|
||||||
- (id) initWithBitmapDataPlanes: (unsigned char **)planes
|
- (id) initWithBitmapDataPlanes: (unsigned char **)planes
|
||||||
pixelsWide: (int)width
|
pixelsWide: (int)width
|
||||||
pixelsHigh: (int)height
|
pixelsHigh: (int)height
|
||||||
bitsPerSample: (int)bps
|
bitsPerSample: (int)bps
|
||||||
samplesPerPixel: (int)spp
|
samplesPerPixel: (int)spp
|
||||||
hasAlpha: (BOOL)alpha
|
hasAlpha: (BOOL)alpha
|
||||||
isPlanar: (BOOL)config
|
isPlanar: (BOOL)isPlanar
|
||||||
colorSpaceName: (NSString *)colorSpaceName
|
colorSpaceName: (NSString *)colorSpaceName
|
||||||
bytesPerRow: (int)rowBytes
|
bytesPerRow: (int)rowBytes
|
||||||
bitsPerPixel: (int)pixelBits;
|
bitsPerPixel: (int)pixelBits;
|
||||||
|
@ -192,10 +190,10 @@
|
||||||
bitsPerSample = bps;
|
bitsPerSample = bps;
|
||||||
numColors = spp;
|
numColors = spp;
|
||||||
hasAlpha = alpha;
|
hasAlpha = alpha;
|
||||||
isPlanar = isPlanar;
|
_isPlanar = isPlanar;
|
||||||
colorSpace = [colorSpaceName retain];
|
_colorSpace = [colorSpaceName retain];
|
||||||
if (!pixelBits)
|
if (!pixelBits)
|
||||||
pixelBits = bps * ((isPlanar) ? 1 : spp);
|
pixelBits = bps * ((_isPlanar) ? 1 : spp);
|
||||||
bitsPerPixel = pixelBits;
|
bitsPerPixel = pixelBits;
|
||||||
if (!rowBytes)
|
if (!rowBytes)
|
||||||
rowBytes = ceil((float)width * bitsPerPixel / 8);
|
rowBytes = ceil((float)width * bitsPerPixel / 8);
|
||||||
|
@ -203,21 +201,18 @@
|
||||||
|
|
||||||
if (planes)
|
if (planes)
|
||||||
{
|
{
|
||||||
freePlanes = YES;
|
int i;
|
||||||
imagePlanes = planes;
|
OBJC_MALLOC(imagePlanes, unsigned char*, MAX_PLANES);
|
||||||
|
for (i = 0; i < MAX_PLANES; i++)
|
||||||
|
imagePlanes[i] = NULL;
|
||||||
|
for (i = 0; i < ((_isPlanar) ? numColors : 1); i++)
|
||||||
|
imagePlanes[i] = planes[i];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
if (imagePlanes && freePlanes)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < MAX_PLANES; i++)
|
|
||||||
if (imagePlanes[i])
|
|
||||||
OBJC_FREE(imagePlanes[i]);
|
|
||||||
}
|
|
||||||
OBJC_FREE(imagePlanes);
|
OBJC_FREE(imagePlanes);
|
||||||
[imageData release];
|
[imageData release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -271,12 +266,12 @@
|
||||||
|
|
||||||
- (BOOL) isPlanar
|
- (BOOL) isPlanar
|
||||||
{
|
{
|
||||||
return isPlanar;
|
return _isPlanar;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) numberOfPlanes
|
- (int) numberOfPlanes
|
||||||
{
|
{
|
||||||
return (isPlanar) ? numColors : 1;
|
return (_isPlanar) ? numColors : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) bytesPerPlane
|
- (int) bytesPerPlane
|
||||||
|
@ -307,11 +302,13 @@
|
||||||
long length;
|
long length;
|
||||||
unsigned char* bits;
|
unsigned char* bits;
|
||||||
|
|
||||||
length = numColors * bytesPerRow * _pixelsHigh * sizeof(unsigned char);
|
length = (long)numColors * bytesPerRow * _pixelsHigh
|
||||||
imageData = [NSMutableData dataWithCapacity: length];
|
* sizeof(unsigned char);
|
||||||
OBJC_MALLOC(imagePlanes, unsigned char*, MAX_PLANES);
|
imageData = [[NSMutableData dataWithLength: length] retain];
|
||||||
|
if (!imagePlanes)
|
||||||
|
OBJC_MALLOC(imagePlanes, unsigned char*, MAX_PLANES);
|
||||||
bits = [imageData mutableBytes];
|
bits = [imageData mutableBytes];
|
||||||
if (isPlanar)
|
if (_isPlanar)
|
||||||
{
|
{
|
||||||
for (i=1; i < numColors; i++)
|
for (i=1; i < numColors; i++)
|
||||||
imagePlanes[i] = bits + i*bytesPerRow * _pixelsHigh;
|
imagePlanes[i] = bits + i*bytesPerRow * _pixelsHigh;
|
||||||
|
@ -320,7 +317,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imagePlanes[1] = bits;
|
imagePlanes[0] = bits;
|
||||||
for (i= 1; i < MAX_PLANES; i++)
|
for (i= 1; i < MAX_PLANES; i++)
|
||||||
imagePlanes[i] = NULL;
|
imagePlanes[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,10 +85,12 @@ _base_name(NSString *name)
|
||||||
static NSString *
|
static NSString *
|
||||||
extension(NSString *name)
|
extension(NSString *name)
|
||||||
{
|
{
|
||||||
|
const char* cname;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = strrchr([name cString], '.');
|
cname = [name cString];
|
||||||
if (s > strrchr([name cString], '/'))
|
s = strrchr(cname, '.');
|
||||||
|
if (s > strrchr(cname, '/'))
|
||||||
return [NSString stringWithCString:s+1];
|
return [NSString stringWithCString:s+1];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -56,10 +56,12 @@ extension(NSString *name)
|
||||||
#if 0
|
#if 0
|
||||||
return [name pathExtension];
|
return [name pathExtension];
|
||||||
#else
|
#else
|
||||||
|
const char* cname;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = strrchr([name cString], '.');
|
cname = [name cString];
|
||||||
if (s > strrchr([name cString], '/'))
|
s = strrchr(cname, '.');
|
||||||
|
if (s > strrchr(cname, '/'))
|
||||||
return [NSString stringWithCString:s+1];
|
return [NSString stringWithCString:s+1];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -72,9 +74,12 @@ extension(NSString *name)
|
||||||
{
|
{
|
||||||
/* While there are four imageRep subclasses, in practice, only two of
|
/* While there are four imageRep subclasses, in practice, only two of
|
||||||
them can load in data from an external source. */
|
them can load in data from an external source. */
|
||||||
imageReps = [[NSMutableArray alloc] initWithCapacity: 2];
|
if (self == [NSImageRep class])
|
||||||
[imageReps addObject: [NSBitmapImageRep class]];
|
{
|
||||||
[imageReps addObject: [NSEPSImageRep class]];
|
imageReps = [[NSMutableArray alloc] initWithCapacity: 2];
|
||||||
|
[imageReps addObject: [NSBitmapImageRep class]];
|
||||||
|
[imageReps addObject: [NSEPSImageRep class]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creating an NSImageRep
|
// Creating an NSImageRep
|
||||||
|
@ -104,23 +109,24 @@ extension(NSString *name)
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
Class rep = [imageReps objectAtIndex: i];
|
Class rep = [imageReps objectAtIndex: i];
|
||||||
|
#if 1
|
||||||
if ([[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
if ([[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
||||||
{
|
#else
|
||||||
NSData* data = [NSData dataWithContentsOfFile: filename];
|
/* xxxFIXME: not implemented in gcc-2.7.2 runtime. */
|
||||||
if ([rep class] == [NSBitmapImageRep class])
|
if ([rep respondsToSelector: @selector(imageFileTypes)]
|
||||||
[array addObject: [rep imageRepWithData: data]];
|
&& [[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
if ([rep respondsToSelector: @selector(imageFileTypes)]
|
|
||||||
&& [[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
|
||||||
{
|
|
||||||
NSData* data = [NSData dataWithContentsOfFile: filename];
|
|
||||||
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
|
||||||
[array addObjectsFromArray: [rep imageRepsWithData: data]];
|
|
||||||
else if ([rep respondsToSelector: @selector(imageRepWithData:)])
|
|
||||||
[array addObject: [rep imageRepWithData: data]];
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
NSData* data = [NSData dataWithContentsOfFile: filename];
|
||||||
|
#if 0
|
||||||
|
if ([rep respondsToSelector: @selector(imageRepsWithData:)])
|
||||||
|
#endif
|
||||||
|
[array addObjectsFromArray: [rep imageRepsWithData: data]];
|
||||||
|
#if 0
|
||||||
|
else if ([rep respondsToSelector: @selector(imageRepWithData:)])
|
||||||
|
[array addObject: [rep imageRepWithData: data]];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (NSArray *)array;
|
return (NSArray *)array;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +169,7 @@ extension(NSString *name)
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[colorSpace release];
|
[_colorSpace release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +229,7 @@ extension(NSString *name)
|
||||||
|
|
||||||
- (NSString *) colorSpaceName
|
- (NSString *) colorSpaceName
|
||||||
{
|
{
|
||||||
return colorSpace;
|
return _colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) hasAlpha
|
- (BOOL) hasAlpha
|
||||||
|
@ -258,8 +264,8 @@ extension(NSString *name)
|
||||||
|
|
||||||
- (void) setColorSpaceName: (NSString *)aString
|
- (void) setColorSpaceName: (NSString *)aString
|
||||||
{
|
{
|
||||||
[colorSpace autorelease];
|
[_colorSpace autorelease];
|
||||||
colorSpace = [aString retain];
|
_colorSpace = [aString retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setOpaque: (BOOL)flag
|
- (void) setOpaque: (BOOL)flag
|
||||||
|
@ -346,9 +352,11 @@ extension(NSString *name)
|
||||||
+ (void) registerImageRepClass: (Class)imageRepClass
|
+ (void) registerImageRepClass: (Class)imageRepClass
|
||||||
{
|
{
|
||||||
[imageReps addObject: imageRepClass];
|
[imageReps addObject: imageRepClass];
|
||||||
|
/*
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSImageRepRegistryChangedNotification
|
postNotificationName: NSImageRepRegistryChangedNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *) registeredImageRepClasses
|
+ (NSArray *) registeredImageRepClasses
|
||||||
|
@ -369,7 +377,7 @@ extension(NSString *name)
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
[aCoder encodeObject: colorSpace];
|
[aCoder encodeObject: _colorSpace];
|
||||||
[aCoder encodeSize: size];
|
[aCoder encodeSize: size];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
||||||
|
@ -382,7 +390,7 @@ extension(NSString *name)
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aDecoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
colorSpace = [[aDecoder decodeObject] retain];
|
_colorSpace = [[aDecoder decodeObject] retain];
|
||||||
size = [aDecoder decodeSize];
|
size = [aDecoder decodeSize];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue