Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.

NXBitmapImageRep



Inherits From: NXImageRep : Object
Declared In: appkit/NXBitmapImageRep.h



Class Description

An NXBitmapImageRep is an object that can render an image from bitmap data.  The data can be in Tag Image File Format (TIFF), or it can be raw image data.  If it's raw data, the object must be informed about the structure of the image--its size, the number of color components, the number of bits per sample, and so on--when it's first initialized.  If it's TIFF data, the object can get this information from the various TIFF fields included with the data.

Although NXBitmapImageReps are often used indirectly, through instances of the NXImage class, they can also be used directly--for example to manipulate the bits of an image as you might need to do in a paint program.



Setting Up an NXBitmapImageRep

A new NXBitmapImageRep is passed bitmap data for an image--or told where to find it--when it's first initialized:

TIFF data can be read from a stream, from a file, or from a section of the _ _TIFF segment of the application executable.  If it's stored in a section or a separate file, the object will delay reading the data until it's needed.
Raw bitmap data is placed in buffers, and pointers to the buffers are passed to the object.

An NXBitmapImageRep can also be created from bitmap data that's read from an existing (already rendered) image.  The object created from this data is able to reproduce the image.

Although the NXBitmapImageRep class inherits NXImageRep methods that set image attributes, these methods shouldn't be used.  Instead, you should either allow the object to find out about the image from the TIFF fields or use methods defined in this class to supply this information when the object is initialized.



TIFF Compression

TIFF data can be read and rendered after it has been compressed using any one of the four schemes briefly described below:

LZW Compresses and decompresses without information loss, achieving compression ratios of anywhere from 2:1 to 3:1.  It may be somewhat slower to compress and decompress than the PackBits scheme.
PackBits Compresses and decompresses without information loss, but may not achieve the same compression ratios as LZW.
JPEG Compresses and decompresses with some information loss, but can achieve compression ratios anywhere from 10:1 to 100:1.  The ratio is determined by a user-settable factor ranging from 1.0 to 255.0, with higher factors yielding greater compression.  More information is lost with greater compression, but 15:1 compression is safe for publication quality.  Some images can be compressed even more.  JPEG compression can be used only for images that specify at least 4 bits per sample.
CCITTFAX Compresses and decompresses 1 bit grayscale images using international fax compression standards CCITT3 and CCITT4.

An NXBitmapImageRep can also produce compressed TIFF data for its image using any of these schemes.



Instance Variables

None declared in this class.



Method Types

Initializing a new NXBitmapImageRep object
initFromSection:
initFromFile:
initFromStream:
initData:fromRect:
initData:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpace:
bytesPerRow:bitsPerPixel:
initDataPlanes:pixelsWide:pixelsHigh:
bitsPerSample:samplesPerPixel:hasAlpha:
isPlanar:colorSpace:bytesPerRow:bitsPerPixel:
Creating a List of NXBitmapImageReps
+ newListFromSection:
+ newListFromSection:zone:
+ newListFromFile:
+ newListFromFile:zone:
+ newListFromStream:
+ newListFromStream:zone:
Reading information from a rendered image
+ sizeImage:
+ sizeImage:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpace:
Copying and freeing an NXBitmapImageRep
copyFromZone:
free
Getting information about the image
bitsPerPixel
samplesPerPixel
bitsPerSample (NXImageRep)
isPlanar
numPlanes
numColors (NXImageRep)
hasAlpha (NXImageRep)
bytesPerPlane
bytesPerRow
colorSpace
pixelsWide (NXImageRep)
pixelsHigh (NXImageRep)
Getting image data data
getDataPlanes:
Drawing the image draw
drawIn:
drawAt: (NXImageRep)
Producing a TIFF representation of the image
writeTIFF:
writeTIFF:usingCompression:
writeTIFF:usingCompression:andFactor:
Setting/checking compression types
+ getTIFFCompressionTypes:count:
+ localizedNameForTIFFCompressionType:
canBeCompressedUsing:
getCompression:andFactor:
setCompression:andFactor:
Checking unpacked data handling
+ setUnpackedImageDataAcceptable:
+ isUnpackedImageDataAcceptable
Archiving read:
write:



Class Methods

getTIFFCompressionTypes:count:
+ (void)getTIFFCompressionTypes:(const int **)list count:(int *)numTypes

Returns, by reference, an integer array representing all available compression types that can be used when writing a TIFF image.  The number of elements in list is represented by numTypeslist belongs to the NXBitmapImageRep class; it shouldn't be freed or altered.

The following compression types are supported:

Constant Value Usage
NX_TIFF_COMPRESSION_NONE 1
NX_TIFF_COMPRESSION_CCITTFAX3 3 1 bps images only
NX_TIFF_COMPRESSION_CCITTFAX4 4 1 bps images only
NX_TIFF_COMPRESSION_LZW 5
NX_TIFF_COMPRESSION_JPEG 6
NX_TIFF_COMPRESSION_NEXT 32766 Input only
NX_TIFF_COMPRESSION_PACKBITS 32773
NX_TIFF_COMPRESSION_OLDJPEG 32865 Input only

Note that not all compression types can be used for all images: NX_TIFF_COMPRESSION_NEXT can be used only to retrieve image data.  Because future releases of NEXTSTEP may include other compression types, always use this method to get the available compression types--for example, when you implement a user interface for selecting compression types.

See also:  + localizedNameForTIFFCompressionType:, canBeCompressedUsing:



isUnpackedImageDataAcceptable
+ (BOOL)isUnpackedImageDataAcceptable

Returns YES if the NXBitmapImageRep class can accept unpacked image data.  You can  set the value returned by this method through the setUnpackedImageDataAcceptable: class method.

See also:  + setUnpackedImageDataAcceptable:



localizedNameForTIFFCompressionType:
+ (const char *)localizedNameForTIFFCompressionType:(int)compression

Returns a string containing the localized name for the compression type represented by compression; returns NULL if compression is unrecognized.  Compression types are listed in the getTIFFCompressionTypes:count: class method description.  When implementing a user interface for selecting TIFF compression types, use the getTIFF... method to get the list of supported compression types, then use this method to get the localized names for each compression type.

The returned string belongs to the NXBitmapImageRep class; don't attempt to alter or free it.

See also:  + getTIFFCompressionTypes:count:



newListFromFile:
+ (List *)newListFromFile:(const char *)filename

Creates one new NXBitmapImageRep instance for each TIFF image specified in the filename file, and returns a List object containing all the objects created.  If no NXBitmapImageReps can be created (for example, if filename doesn't exist or doesn't contain TIFF data), nil is returned.  The List should be freed when it's no longer needed.

Each new NXBitmapImageRep is initialized by the initFromFile: method, which reads information about the image from filename, but not the image data.  The data will be read when it's needed to render the image.

See also:  + newListFromFile:zone:, initFromFile:



newListFromFile:zone:
+ (List *)newListFromFile:(const char *)filename zone:(NXZone *)aZone

Returns a List of new NXBitmapImageRep instances, just as newListFromFile: does, except that the List object and the NXBitmapImageReps are allocated from memory located in aZone.

See also:  + newListFromFile:, initFromFile:



newListFromSection:
+ (List *)newListFromSection:(const char *)name

Creates one new NXBitmapImageRep instance for each TIFF image specified in the name section of the _ _TIFF segment in the executable file or in the name file in the application bundle, and returns a List object containing all the objects created.  If not even one NXBitmapImageRep can be created (for example, if the name section doesn't exist or doesn't contain TIFF data), nil is returned.  The List should be freed when it's no longer needed.

Each new NXBitmapImageRep is initialized by the initFromSection: method, which reads information about the image from the section, but doesn't read image data.  The data will be read when it's needed to render the image.

See also:  + newListFromSection:zone:, initFromSection:



newListFromSection:zone:
+ (List *)newListFromSection:(const char *)name zone:(NXZone *)aZone

Returns a List of new NXBitmapImageRep instances, just as newListFromSection: does, except that the List object and the NXBitmapImageReps are allocated from memory located in aZone.

See also:  + newListFromSection:, initFromSection:



newListFromStream:
+ (List *)newListFromStream:(NXStream *)stream

Creates one new NXBitmapImageRep instance for each TIFF image that can be read from stream, and returns a List object containing all the objects created.  If not even one NXBitmapImageRep can be created (for example, if the stream doesn't contain TIFF data), nil is returned.  The List should be freed when it's no longer needed.

The data is read and each new object initialized by the initFromStream: method.

See also:  + newListFromStream:zone:, initFromStream:



newListFromStream:zone:
+ (List *)newListFromStream:(NXStream *)stream zone:(NXZone *)aZone

Returns a List of new NXBitmapImageRep instances, just as newListFromStream: does, except that the NXBitmapImageReps and the List object are allocated from memory located in aZone.

See also:  + newListFromStream:, initFromStream:



setUnpackedImageDataAcceptable:
+ (void)setUnpackedImageDataAcceptable:(BOOL)flag

If flag is YES, sets the receiver to accept unpacked image data.

See also:  + isUnpackedImageDataAcceptable



sizeImage:
+ (int)sizeImage:(const NXRect *)rect

Returns the number of bytes that would be required to hold bitmap data for the rendered image bounded by the rect rectangle. The rectangle is located in the current window and is specified in the current coordinate system.

See also:  + sizeImage:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:
hasAlpha:isPlanar:colorSpace:, initData:fromRect:



sizeImage:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:
hasAlpha:isPlanar:colorSpace:
+ (int)sizeImage:(const NXRect *)rect
pixelsWide:(int *)width
pixelsHigh:(int *)height
bitsPerSample:(int *)bps
samplesPerPixel:(int *)spp
hasAlpha:(BOOL *)alpha
isPlanar:(BOOL *)config
colorSpace:(NXColorSpace *)space

Returns the number of bytes that would be required to hold bitmap data for the rendered image bounded by the rect rectangle. The rectangle is located in the current window and is specified in the current coordinate system.

Every argument but rect is a pointer to a variable where the method will write information about the image.  For an explanation of the information provided, see the description of the initDataPlanes:... method

See also:  initDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:



Instance Methods

bitsPerPixel
(int)bitsPerPixel

Returns the number of bits allocated for each pixel in each plane of data.  This is normally equal to the number of bits per sample or, if the data is in meshed configuration, the number of bits per sample times the number of samples per pixel.  It can be explicitly set to another value (in the initData:... or initDataPlanes:... method) in case extra memory is allocated for each pixel. This may be the case, for example, if pixel data is aligned on byte boundaries.



bytesPerPlane
(int)bytesPerPlane

Returns the number of bytes in each plane or channel of data.  This will be figured from the number of bytes per row and the height of the image.

See also:  bytesPerRow



bytesPerRow
(int)bytesPerRow

Returns the minimum number of bytes required to specify a scan line (a single row of pixels spanning the width of the image) in each data plane.  If not explicitly set to another value (in the initData:... or initDataPlanes:... method), this will be figured from the width of the image, the number of bits per sample, and, if the data is in a meshed configuration, the number of samples per pixel.  It can be set to another value to indicate that each row of data is aligned on word or other boundaries.



canBeCompressedUsing:
(BOOL)canBeCompressedUsing:(int)compression

Tests whether the receiver can be compressed by compression type.  Compression types are defined in appkit/tiff.h.  This method returns YES if the receiver's data matches compression; for example, if compression is NX_TIFF_COMPRESSION_CCITTFAX3, then the data must be one bit-per-sample and one sample-per-pixel.  It returns NO if the data doesn't match compression or if compression is unsupported.

See also:  + getTIFFCompressionTypes:count:



colorSpace
(NXColorSpace)colorSpace

Returns one of the following enumerated values, which indicate how bitmap data is to be interpreted:

NX_OneIsBlackColorSpace A gray scale between 1 (black) and 0 (white)
NX_OneIsWhiteColorSpace A gray scale between 0 (black) and 1 (white)
NX_RGBColorSpace Red, green, and blue color values
NX_CMYKColorSpace Cyan, magenta, yellow, and black color values

See also:  numColors (NXImageRep)



copyFromZone:
copyFromZone:(NXZone *)zone

Returns a new NXBitmapImageRep instance that's an exact copy of the receiver.  The new object is allocated from zone.  It will have its own copy of the bitmap data, also allocated from zone, unless the receiver merely references the data.  In that case, both objects will reference the same data.

See also:  copy (Object)



data
(unsigned char *)data

Returns a pointer to the bitmap data.  If the data is in planar configuration, this pointer will be to the first plane.  To get separate pointers to each plane, use the getDataPlanes: method.

See also:  getDataPlanes:



draw
(BOOL)draw

Renders the image at (0.0, 0.0) in the current coordinate system on the current device using the appropriate PostScript imaging operator.  This method returns YES if successful in producing the image, and NO if not.

See also:  drawAt: (NXImageRep), drawIn:



drawIn:
(BOOL)drawIn:(const NXRect *)rect

Renders the image so that it fits inside the rectangle referred to by rect.  The current coordinate system is translated and scaled so the image will appear at the right location and fit within the rectangle.  The draw method is then invoked to render the image. This method passes through the return value of the draw method, which indicates whether the image was successfully drawn.

The coordinate system is not restored after it has been altered.

See also:  draw, drawAt: (NXImageRep)



free
free

Deallocates the NXBitmapImageRep.  This method will not free any bitmap data that the object merely references--that is, raw data that was passed to it in a initData:... or initDataPlanes:... message.



getCompression:andFactor:
(void)getCompression:(int *)compression andFactor:(float *)factor

Returns by reference the receiver's compression type and compression factor.  Use this method to get information on the compression type for the source image data.  compression represents the compression type used on the data, and corresponds to one of the values returned by the class method getTIFFCompressionTypes:count:factor is usually a value between 0.0 and 255.0, with 0.0 representing no compression.

See also:  + getTIFFCompressionTypes:count:, setCompression:andFactor:



getDataPlanes:
getDataPlanes:(unsigned char **)thePlanes

Provides bitmap data for the image separated into planes.  thePlanes should be an array of five character pointers.  If the bitmap data is in planar configuration, each pointer will be initialized to point to one of the data planes.  If there are less than five planes, the remaining pointers will be set to NULL.  If the bitmap data is in meshed configuration, only the first pointer will be initialized; the others will be NULL.  Returns self.

Color components in planar configuration are arranged in the expected order--for example, red before green before blue for RGB color.  All color planes precede the coverage plane.

See also:  data, isPlanar



init

Generates an error message.  This method cannot be used to initialize an NXBitmapImageRep.  Instead, use one of the initFrom... or initData... methods.

See also:  initFromSection:, initFromFile:, initFromStream:,
initDataPlanes:..., initData:...



initData:fromRect:
initData:(unsigned char *)data fromRect:(const NXRect *)rect

Initializes the receiver, a newly allocated NXBitmapImageRep object, with bitmap data read from a rendered image.  The image that's read is located in the current window and is bounded by the rect rectangle as specified in the current coordinate system.

This method uses PostScript imaging operators to read the image data into the data buffer; the object is then created from that data.  The object is initialized with information about the image obtained from the Window Server.

If data is NULL, the NXBitmapImageRep will allocate enough memory to hold bitmap data for the image.  In this case, the buffer will belong to the object and will be freed when the object is freed.  This is the most efficient way to allocate memory for the bitmap.

If data is not NULL, you must make sure the buffer is large enough to hold the image bitmap.  You can determine how large it needs to be by sending a sizeImage: message for the same rectangle.  The NXBitmapImageRep will only reference the data in the buffer; the buffer won't be freed when the object is freed.

If for any reason the new object can't be initialized, this method frees it and returns nil.  Otherwise, it returns the initialized object (self).

See also:  + sizeImage:



initData:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:
hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:
initData:(unsigned char *)data
pixelsWide:(int)width
pixelsHigh:(int)height
bitsPerSample:(int)bps
samplesPerPixel:(int)spp
hasAlpha:(BOOL)alpha
isPlanar:(BOOL)config
colorSpace:(NXColorSpace)space
bytesPerRow:(int)rowBytes
bitsPerPixel:(int)pixelBits

Initializes the receiver, a newly allocated NXBitmapImageRep object, so that it can render the image specified in data and described by the other arguments.  If the object can't be initialized, this method frees it and returns nil.  Otherwise, it returns the object (self).

data points to a buffer containing raw bitmap data.  If the data is in planar configuration (config is YES), all the planes must follow each other in the same buffer.  The initDataPlanes:... method can be used instead of this one if there are separate buffers for each plane.

If data is NULL, this method allocates a data buffer large enough to hold the image described by the other arguments.  You can then obtain a pointer to this buffer (with the data or getDataPlanes: method) and fill in the image data.  In this case the buffer will belong to the object and will be freed when it's freed.

If data is not NULL, the object will only reference the image data; it won't copy it.  The buffer won't be freed when the object is freed.

All the other arguments to this method are the same as those to initDataPlanes:....  See that method for descriptions.

See also:  initDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:



initDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:
hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:
initDataPlanes:(unsigned char **)planes
pixelsWide:(int)width
pixelsHigh:(int)height
bitsPerSample:(int)bps
samplesPerPixel:(int)spp
hasAlpha:(BOOL)alpha
isPlanar:(BOOL)config
colorSpace:(NXColorSpace)space
bytesPerRow:(int)rowBytes
bitsPerPixel:(int)pixelBits

Initializes the receiver, a newly allocated NXBitmapImageRep object, so that it can render the image specified in planes and described by the other arguments.  If the object can't be initialized, this method frees it and returns nil.  Otherwise, it returns the object (self).

planes is an array of character pointers, each of which points to a buffer containing raw image data.  If the data is in planar configuration, each buffer holds one component--one plane--of the data.  Color planes are arranged in the standard order--for example, red before green before blue for RGB color.  All color planes precede the coverage plane.

If the data is in meshed configuration (config is NO), only the first buffer is read.  The initData:... method can be used instead of this one for data in meshed configuration.

If planes is NULL or if it's an array of NULL pointers, this method allocates enough memory to hold the image described by the other arguments.  You can then obtain pointers to this memory (with the getDataPlanes: or data method) and fill in the image data.  In this case, the allocated memory will belong to the object and will be freed when it's freed.

If planes is not NULL and the array contains at least one data pointer, the object will only reference the image data; it won't copy it.  The buffers won't be freed when the object is freed.

Each of the other arguments (besides planes) informs the NXBitmapImageRep object about the image.  They're explained below:

width and height specify the size of the image in pixels.  The size in each direction must be greater than 0.
bps (bits per sample) is the number of bits used to specify one pixel in a single component of the data.  All components are assumed to  have the same bits per sample.
spp (samples per pixel) is the number of data components.  It includes both color components and the coverage component (alpha), if present.  Meaningful values range from 1 through 5.  An image with cyan, magenta, yellow, and black (CMYK) color components plus a coverage component would have an spp of 5; a gray-scale image that lacks a coverage component would have an spp of 1.
alpha should be YES if one of the components counted in the number of samples per pixel (spp) is a coverage component, and NO if there is no coverage component.
config should be YES if the data components are laid out in a series of separate "planes" or channels ("planar configuration"), and NO if component values are interwoven in a single channel ("meshed configuration").
For example, in meshed configuration, the red, green, blue, and coverage values for the first pixel of an image would precede the red, green, blue, and coverage values for the second pixel, and so on.  In planar configuration, red values for all the pixels in the image would precede all green values, which would precede all blue values, which would precede all coverage values.
space indicates how data values are to be interpreted.  It should be one of the following enumerated values:

NX_OneIsBlackColorSpace A gray scale between 1 (black) and 0 (white)
NX_OneIsWhiteColorSpace A gray scale between 0 (black) and 1 (white)
NX_RGBColorSpace Red, green, and blue color values
NX_CMYKColorSpace Cyan, magenta, yellow, and black color values

rowBytes is the number of bytes that are allocated for each scan line in each plane of data.  A scan line is a single row of pixels spanning the width of the image.
Normally, rowBytes can be figured from the width of the image, the number of bits per pixel in each sample (bps), and, if the data is in a meshed configuration, the number of samples per pixel (spp).  However, if the data for each row is aligned on word or other boundaries, it may have been necessary to allocate more memory for each row than there is data to fill it. rowBytes lets the object know whether that's the case.  If rowBytes is 0, the NXBitmapImageRep assumes that there's no empty space at the end of a row.
pixelBits informs the NXBitmapImageRep how many bits are actually allocated per pixel in each plane of data.  If the data is in planar configuration, this normally equals bps (bits per sample).  If the data is in meshed configuration, it normally equals bps times spp (samples per pixel).  However, it's possible for a pixel specification to be followed by some meaningless bits (empty space), as may happen, for example, if pixel data is aligned on byte boundaries.  Currently, an NXBitmapImageRep cannot render an image if this is the case.
If pixelBits is 0, the object will interpret the number of bits per pixel to be the expected value, without any meaningless bits.

This method is the designated initializer for NXBitmapImageReps that handle raw image data.

See also:  initData:pixelsWide:pixelsHigh:...



initFromFile:
initFromFile:(const char *)filename

Initializes the receiver, a newly allocated NXBitmapImageRep object, with the TIFF image found in the  filename file.  This method reads some information about the image from filename, but not the image itself.  Image data will be read when it's needed to render the image.

If the new object can't be initialized for any reason (for example, filename doesn't exist or doesn't contain TIFF data), this method frees it and returns nil.  Otherwise, it returns self.

This method is the designated initializer for NXBitmapImageReps that read image data from a file.

See also:  + newListFromFile:, initFromSection:



initFromSection:
initFromSection:(const char *)name

Initializes the receiver, a newly allocated NXBitmapImageRep object, with the TIFF image found in the  name section in the _ _TIFF segment of the application executable or the name file in the application bundle.  This method reads some information about the image from the section, but not the image itself.  Image data is read only when it's needed to render the image.

If the new object can't be initialized for any reason (for example, the name section doesn't exist or doesn't contain TIFF data), this method frees it and returns nil.  Otherwise, it returns self.

This method is the designated initializer for NXBitmapImageReps that read image data from the application's executable file or bundle.

See also:  + newListFromSection:, initFromFile:



initFromStream:
initFromStream:(NXStream *)stream

Initializes the receiver, a newly allocated NXBitmapImageRep object, with the TIFF image read from stream.  If the new object can't be initialized for any reason (for example, stream doesn't contain TIFF data), this method frees it and returns nil. Otherwise, it returns self.

This method is the designated initializer for NXBitmapImageReps that read image data from a stream.

See also:  + newListFromStream:



isPlanar
(BOOL)isPlanar

Returns YES if image data is segregated into a separate plane for each color and coverage component (planar configuration), and NO if the data is integrated into a single plane (meshed configuration).

See also:  samplesPerPixel



numPlanes
(int)numPlanes

Returns the number of separate planes that image data is organized into.  This will be the number of samples per pixel if the data has a separate plane for each component (isPlanar returns YES) and 1 if the data is meshed (isPlanar returns NO).

See also:  isPlanar, samplesPerPixel, hasAlpha, numColors (NXImageRep)



read:
read:(NXTypedStream *)stream

Reads the NXBitmapImageRep from the typed stream stream.

See also:  write:



samplesPerPixel
(int)samplesPerPixel

Returns the number of components in the data.  It includes both color components and the coverage component, if present.

See also:  hasAlpha, numColors (NXImageRep)



setCompression:andFactor:
(void)setCompression:(int)compression andFactor:(float)factor

Sets the receiver's compression type and compression factor.  compression is one of the supported compression types listed in the getTiffCompressionTypes:count: class method description.  factor is a compression factor, usually between 0.0 (no compression) and 255.0 (maximum compression).

When an NXBitmapImageRep is created, the instance stores the compression type and factor for the source data.  When the data is subsequently saved, writeTIFF: tries to use the stored compression type and factor.  Use this method to change the compression type and factor.

See also:  + getTiffCompressionTypes:count:, getCompression:andFactor:



write:
write:(NXTypedStream *)stream

Writes the NXBitmapImageRep to the typed stream stream.

See also:  read:



writeTIFF:
writeTIFF:(NXStream *)stream

Writes a TIFF representation of the image to stream.  This method invokes writeTIFF:usingCompression:andFactor: using the stored compression type and factor retrieved from the initial image data or changed using setCompression:andFactor:.  If the stored compression type isn't supported for writing TIFF data (for example, NX_TIFF_COMPRESSION_NEXT), the stored compression is changed to NX_TIFF_COMPRESSION_NONE and the compression factor to 0.0 before invoking writeTIFF:usingCompression:andFactor:

See also:  getCompression:andFactor:, setCompression:andFactor:writeTIFF:usingCompression:andFactor:



writeTIFF:usingCompression:
writeTIFF:(NXStream *)stream usingCompression:(int)compression

Writes a TIFF representation of the image to stream, compressing the data according to the compression scheme.  If compression is NX_TIFF_COMPRESSION_JPEG, the default compression factor is used.  This and the other compression constants are listed under the next method.

See also:  writeTIFF:usingCompression:andFactor:



writeTIFF:usingCompression:andFactor:
writeTIFF:(NXStream *)stream
usingCompression:(int)compression
andFactor:(float)factor

Writes a TIFF representation of the image to stream.  If the stream isn't currently positioned at location 0, this method assumes that it contains another TIFF image.  It will try to append the TIFF representation it writes to that image.  To do this, it must read the header of the image already in the stream.  Therefore, the stream must be opened with NX_READWRITE permission.

The second argument, compression, indicates the compression scheme to use.  It should be one of the following constants:

NX_TIFF_COMPRESSION_NONE No compression
NX_TIFF_COMPRESSION_LZW LZW compression
NX_TIFF_COMPRESSION_PACKBITS PackBits compression
NX_TIFF_COMPRESSION_JPEG JPEG compression
NX_TIFF_COMPRESSION_CCITTFAX3 CCITT Level 3 fax (1 bps data only)
NX_TIFF_COMPRESSION_CCITTFAX4 CCITT Level 4 fax (1 bps data only)

The third argument, factor, is used in the JPEG scheme to determine the degree of compression.  If factor is 0.0, the default compression factor of 10.0 will be used.  Otherwise, factor should fall within the range 1.0255.0, with higher values yielding greater compression but also greater information loss.

The compression schemes are discussed briefly in the class description, above.