mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +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
56671bb537
commit
6991ce1d91
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>
|
||||
|
||||
Create initial documentation set.
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
unsigned int numColors;
|
||||
unsigned int bitsPerPixel;
|
||||
unsigned short compression;
|
||||
BOOL isPlanar;
|
||||
BOOL freePlanes;
|
||||
BOOL _isPlanar;
|
||||
unsigned char** imagePlanes;
|
||||
NSMutableData* imageData;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
{
|
||||
// Attributes
|
||||
NSString* colorSpace;
|
||||
NSString* _colorSpace;
|
||||
NSSize size;
|
||||
BOOL hasAlpha;
|
||||
BOOL isOpaque;
|
||||
|
|
|
@ -163,18 +163,16 @@
|
|||
}
|
||||
|
||||
/* This is the designated initializer */
|
||||
/* Note: It's unclear whether or not we own the data that is passed
|
||||
to us here. Since the data is not of type "const", one could assume
|
||||
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. */
|
||||
/* Note: If data is actaully passed to us in planes, we DO NOT own this
|
||||
data and we DO NOT copy it. Just assume that it will always be available.
|
||||
*/
|
||||
- (id) initWithBitmapDataPlanes: (unsigned char **)planes
|
||||
pixelsWide: (int)width
|
||||
pixelsHigh: (int)height
|
||||
bitsPerSample: (int)bps
|
||||
samplesPerPixel: (int)spp
|
||||
hasAlpha: (BOOL)alpha
|
||||
isPlanar: (BOOL)config
|
||||
isPlanar: (BOOL)isPlanar
|
||||
colorSpaceName: (NSString *)colorSpaceName
|
||||
bytesPerRow: (int)rowBytes
|
||||
bitsPerPixel: (int)pixelBits;
|
||||
|
@ -192,10 +190,10 @@
|
|||
bitsPerSample = bps;
|
||||
numColors = spp;
|
||||
hasAlpha = alpha;
|
||||
isPlanar = isPlanar;
|
||||
colorSpace = [colorSpaceName retain];
|
||||
_isPlanar = isPlanar;
|
||||
_colorSpace = [colorSpaceName retain];
|
||||
if (!pixelBits)
|
||||
pixelBits = bps * ((isPlanar) ? 1 : spp);
|
||||
pixelBits = bps * ((_isPlanar) ? 1 : spp);
|
||||
bitsPerPixel = pixelBits;
|
||||
if (!rowBytes)
|
||||
rowBytes = ceil((float)width * bitsPerPixel / 8);
|
||||
|
@ -203,21 +201,18 @@
|
|||
|
||||
if (planes)
|
||||
{
|
||||
freePlanes = YES;
|
||||
imagePlanes = planes;
|
||||
int i;
|
||||
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;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (imagePlanes && freePlanes)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_PLANES; i++)
|
||||
if (imagePlanes[i])
|
||||
OBJC_FREE(imagePlanes[i]);
|
||||
}
|
||||
OBJC_FREE(imagePlanes);
|
||||
[imageData release];
|
||||
[super dealloc];
|
||||
|
@ -271,12 +266,12 @@
|
|||
|
||||
- (BOOL) isPlanar
|
||||
{
|
||||
return isPlanar;
|
||||
return _isPlanar;
|
||||
}
|
||||
|
||||
- (int) numberOfPlanes
|
||||
{
|
||||
return (isPlanar) ? numColors : 1;
|
||||
return (_isPlanar) ? numColors : 1;
|
||||
}
|
||||
|
||||
- (int) bytesPerPlane
|
||||
|
@ -307,11 +302,13 @@
|
|||
long length;
|
||||
unsigned char* bits;
|
||||
|
||||
length = numColors * bytesPerRow * _pixelsHigh * sizeof(unsigned char);
|
||||
imageData = [NSMutableData dataWithCapacity: length];
|
||||
OBJC_MALLOC(imagePlanes, unsigned char*, MAX_PLANES);
|
||||
length = (long)numColors * bytesPerRow * _pixelsHigh
|
||||
* sizeof(unsigned char);
|
||||
imageData = [[NSMutableData dataWithLength: length] retain];
|
||||
if (!imagePlanes)
|
||||
OBJC_MALLOC(imagePlanes, unsigned char*, MAX_PLANES);
|
||||
bits = [imageData mutableBytes];
|
||||
if (isPlanar)
|
||||
if (_isPlanar)
|
||||
{
|
||||
for (i=1; i < numColors; i++)
|
||||
imagePlanes[i] = bits + i*bytesPerRow * _pixelsHigh;
|
||||
|
@ -320,7 +317,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
imagePlanes[1] = bits;
|
||||
imagePlanes[0] = bits;
|
||||
for (i= 1; i < MAX_PLANES; i++)
|
||||
imagePlanes[i] = NULL;
|
||||
}
|
||||
|
|
|
@ -85,10 +85,12 @@ _base_name(NSString *name)
|
|||
static NSString *
|
||||
extension(NSString *name)
|
||||
{
|
||||
const char* cname;
|
||||
char *s;
|
||||
|
||||
s = strrchr([name cString], '.');
|
||||
if (s > strrchr([name cString], '/'))
|
||||
cname = [name cString];
|
||||
s = strrchr(cname, '.');
|
||||
if (s > strrchr(cname, '/'))
|
||||
return [NSString stringWithCString:s+1];
|
||||
else
|
||||
return nil;
|
||||
|
|
|
@ -56,10 +56,12 @@ extension(NSString *name)
|
|||
#if 0
|
||||
return [name pathExtension];
|
||||
#else
|
||||
const char* cname;
|
||||
char *s;
|
||||
|
||||
s = strrchr([name cString], '.');
|
||||
if (s > strrchr([name cString], '/'))
|
||||
|
||||
cname = [name cString];
|
||||
s = strrchr(cname, '.');
|
||||
if (s > strrchr(cname, '/'))
|
||||
return [NSString stringWithCString:s+1];
|
||||
else
|
||||
return nil;
|
||||
|
@ -72,9 +74,12 @@ extension(NSString *name)
|
|||
{
|
||||
/* While there are four imageRep subclasses, in practice, only two of
|
||||
them can load in data from an external source. */
|
||||
imageReps = [[NSMutableArray alloc] initWithCapacity: 2];
|
||||
[imageReps addObject: [NSBitmapImageRep class]];
|
||||
[imageReps addObject: [NSEPSImageRep class]];
|
||||
if (self == [NSImageRep class])
|
||||
{
|
||||
imageReps = [[NSMutableArray alloc] initWithCapacity: 2];
|
||||
[imageReps addObject: [NSBitmapImageRep class]];
|
||||
[imageReps addObject: [NSEPSImageRep class]];
|
||||
}
|
||||
}
|
||||
|
||||
// Creating an NSImageRep
|
||||
|
@ -104,23 +109,24 @@ extension(NSString *name)
|
|||
for (i = 0; i < count; i++)
|
||||
{
|
||||
Class rep = [imageReps objectAtIndex: i];
|
||||
#if 1
|
||||
if ([[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
||||
{
|
||||
NSData* data = [NSData dataWithContentsOfFile: filename];
|
||||
if ([rep class] == [NSBitmapImageRep class])
|
||||
[array addObject: [rep imageRepWithData: data]];
|
||||
}
|
||||
#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]];
|
||||
}
|
||||
#else
|
||||
/* xxxFIXME: not implemented in gcc-2.7.2 runtime. */
|
||||
if ([rep respondsToSelector: @selector(imageFileTypes)]
|
||||
&& [[rep imageFileTypes] indexOfObject: ext] != NSNotFound)
|
||||
#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;
|
||||
}
|
||||
|
@ -163,7 +169,7 @@ extension(NSString *name)
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[colorSpace release];
|
||||
[_colorSpace release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -223,7 +229,7 @@ extension(NSString *name)
|
|||
|
||||
- (NSString *) colorSpaceName
|
||||
{
|
||||
return colorSpace;
|
||||
return _colorSpace;
|
||||
}
|
||||
|
||||
- (BOOL) hasAlpha
|
||||
|
@ -258,8 +264,8 @@ extension(NSString *name)
|
|||
|
||||
- (void) setColorSpaceName: (NSString *)aString
|
||||
{
|
||||
[colorSpace autorelease];
|
||||
colorSpace = [aString retain];
|
||||
[_colorSpace autorelease];
|
||||
_colorSpace = [aString retain];
|
||||
}
|
||||
|
||||
- (void) setOpaque: (BOOL)flag
|
||||
|
@ -346,9 +352,11 @@ extension(NSString *name)
|
|||
+ (void) registerImageRepClass: (Class)imageRepClass
|
||||
{
|
||||
[imageReps addObject: imageRepClass];
|
||||
/*
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSImageRepRegistryChangedNotification
|
||||
object: self];
|
||||
*/
|
||||
}
|
||||
|
||||
+ (NSArray *) registeredImageRepClasses
|
||||
|
@ -369,7 +377,7 @@ extension(NSString *name)
|
|||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject: colorSpace];
|
||||
[aCoder encodeObject: _colorSpace];
|
||||
[aCoder encodeSize: size];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
||||
|
@ -382,7 +390,7 @@ extension(NSString *name)
|
|||
{
|
||||
self = [super initWithCoder: aDecoder];
|
||||
|
||||
colorSpace = [[aDecoder decodeObject] retain];
|
||||
_colorSpace = [[aDecoder decodeObject] retain];
|
||||
size = [aDecoder decodeSize];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &hasAlpha];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &isOpaque];
|
||||
|
|
Loading…
Reference in a new issue