Document GSReadRect and update users.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19801 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2004-07-30 13:58:03 +00:00
parent 85abecbc3a
commit 9cd4d1cc7f
4 changed files with 50 additions and 15 deletions

View file

@ -1,3 +1,10 @@
2004-07-30 15:52 Alexander Malmberg <alexander@malmberg.org>
* Headers/AppKit/NSGraphicsContext.h (-GSReadRect:): Document.
* Source/NSBitmapImageRep.m (-initWithFocusedViewRect:): Update for
new key names from GSReadRect:.
* Source/NSGraphicsContext.m (-GSReadRect:): Return nil.
2004-07-29 Adrian Robert <arobert@cogsci.ucsd.edu>
* Documentation/GuiUser/DefaultsSummary.gsdoc: Added some explanation

View file

@ -372,7 +372,41 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
/* ----------------------------------------------------------------------- */
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
@interface NSGraphicsContext (NSGraphics)
@interface NSGraphicsContext (NSGraphics)
/**
<p>
Read raw pixels from the device and return the information as a bitmap.
Pixels are read from the smallest device-pixel aligned rectangle
containing rect (defined in the current graphics state and clipped to
the current window, but not against the clipping path). If the resulting
device rectangle is degenerate, Size will be (0,0) and Data will be nil,
but the other entries in the dictionary will be filled in.
</p><p>
If the device does not support the operation, returns nil.
</p><p>
The returned dictionary contains at least the following keys:
</p>
<deflist>
<term>Data</term><desc>An NSData-instance with the image data.</desc>
<term>Size</term><desc>An NSValue/NSSize with the size in pixels of the
returned image data.</desc>
<term>BitsPerSample</term><desc>An NSValue/unsigned int.</desc>
<term>SamplesPerPixel</term><desc>An NSValue/unsigned int.</desc>
<term>ColorSpace</term><desc>An NSString with the name of the color space the
data is in.</desc>
<term>HasAlpha</term><desc>An NSValue/unsigned int. 0 if the returned image
does not have an alpha channel, 1 if it does.</desc>
<term>Matrix</term><desc>An NSAffineTransform-instance that contains the
transform between current user space and image space for this image.</desc>
</deflist>
*/
- (NSDictionary *) GSReadRect: (NSRect)rect;
/* Soon to be obsolete */

View file

@ -326,21 +326,21 @@ static BOOL supports_lzw_compression = NO;
RELEASE(self);
return nil;
}
_imageData = RETAIN([dict objectForKey: @"ImageData"]);
_imageData = RETAIN([dict objectForKey: @"Data"]);
if (_imageData == nil)
{
NSLog(@"NSBitmapImageRep initWithFocusedViewRect: failed");
RELEASE(self);
return nil;
}
bps = [[dict objectForKey: @"ImageBPS"] intValue];
bps = [[dict objectForKey: @"BitsPerSample"] intValue];
if (bps == 0)
bps = 8;
spp = [[dict objectForKey: @"ImageSPP"] intValue];
alpha = [[dict objectForKey: @"ImageAlpha"] intValue];
size = [[dict objectForKey: @"ImageSize"] sizeValue];
space = [dict objectForKey: @"ImageColorSpace"];
planes[0] = (unsigned char *)[_imageData mutableBytes];
spp = [[dict objectForKey: @"SamplesPerPixel"] intValue];
alpha = [[dict objectForKey: @"HasAlpha"] intValue];
size = [[dict objectForKey: @"Size"] sizeValue];
space = [dict objectForKey: @"ColorSpace"];
planes[0] = (unsigned char *)[_imageData bytes];
self = [self initWithBitmapDataPlanes: planes
pixelsWide: size.width
pixelsHigh: size.height

View file

@ -1454,15 +1454,9 @@ NSGraphicsContext *GSCurrentContext(void)
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
@implementation NSGraphicsContext (NSGraphics)
/** Read the data inside rect (defined in the current graphics state)
and return the information as a bitmap. The dictionary contains
the bitmap data plus various information about the size and format
of the data. The dictionary keys include ImageSize, ImageBPS,
ImageSPP, and ImageData.
*/
- (NSDictionary *) GSReadRect: (NSRect) rect
{
[self subclassResponsibility: _cmd];
return nil;
}