Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSBitmapImageRepMBS class.

NSBitmapImageRepMBS.bitmapImageRepByConvertingToColorSpace(colorSpace as NSColorSpaceMBS, renderingIntent as Integer) as NSBitmapImageRepMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 17.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Converts the image rep to the specified colorspace.

targetSpace: The new colorSpace
renderingIntent: The rendering intent specifies how to handle colors that are not located within the target color space. The supported values are NSColorRenderingIntent.

ConstantValue
Default0
AbsoluteColorimetric1
RelativeColorimetric2
Perceptual3
Saturation4

An NSBitmapImageRep, or nil, if the conversion fails. If the original NSBitmapImageRep already uses that colorSpace, it is returned as is.

Some examples using this method:

NSBitmapImageRepMBS.bitmapImageRepByRetaggingWithColorSpace(newSpace as NSColorSpaceMBS) as NSBitmapImageRepMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Changes the colorSpace tag of the receiver.

newSpace: The desired colorSpace.

Returns an NSBitmapImageRep, or nil, if the conversion fails. If the original NSBitmapImageRep already uses that colorSpace, it is returned as is.

This method will definitely fail if you pass a colorSpace that has a different color space model than the receiver. That is, if your original image is sRGB, you can only retag with some other RGB colorspace.
Available in Mac OS X v10.6 and later.

NSBitmapImageRepMBS.BMPRepresentation(properties as dictionary = nil) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the bitmap as bmp data.

NSBitmapImageRepMBS.canBeCompressedUsing(compression as Integer) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Tests whether the receiver can be compressed by the specified compression scheme.

Returns ture if the receiver's data matches compression with this type, false if the data doesn't match compression or if compression is unsupported..

Legal values for compression can be found in NSBitmapImageRep.h and are described in TIFF Compression in NSBitmapImageReps. This method returns true if the receiver's data matches compression; for example, if compression is NSTIFFCompressionCCITTFAX3, then the data must be 1 bit per sample and 1 sample per pixel.

NSBitmapImageRepMBS.Constructor(data as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a newly allocated NSBitmapImageRep from the provided data.

data: A data object containing image data. The contents of bitmapData can be any supported bitmap format. For TIFF data, the NSBitmapImageRep is initialized from the first header and image data found in bitmapData.

On success the handle property is not zero.

See also:

NSBitmapImageRepMBS.Constructor(pic as Picture)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an NSBitmapImageRep object created from a Core Graphics image object.

pic: A Core Graphics image object (an opaque type) from which to create the receiver. This opaque type is retained.

An NSBitmapImageRep object initialized from the contents of the Core Graphics image or nil if the NSBitmapImageRep couldn't be created.

If you use this method, you should treat the resulting bitmap NSBitmapImageRep object as read only. Because it only retains the value in the cgImage parameter, rather than unpacking the data, accessing the pixel data requires the creation of a copy of that data in memory. Changes to that data are not saved back to the Core Graphics image.

Available in OS X v10.5 and later.

See also:

NSBitmapImageRepMBS.Constructor(pixelsWide as Integer, pixelsHigh as Integer, bitsPerSample as Integer, samplesPerPixel as Integer, hasAlpha as boolean, colorSpaceName as string, bytesPerRow as Integer, bitsPerPixel as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a newly allocated NSBitmapImageRep object, so it can render the specified image.
Example
dim n as new NSImageMBS(300,300)
dim r as new NSBitmapImageRepMBS(300, 300, 8, 4, true, NSColorSpaceMBS.NSCalibratedRGBColorSpace, 4*300, 32)

dim g as new NSGraphicsMBS(r)
g.SetColorRGB 1.0,0,0,0.5
g.fillRect 0, 0, 100, 100
g = nil // flush
n.addRepresentation r

Backdrop = n.CopyPictureWithMask

The image bitmap data is allocated for you.

pixelsWide: The width of the image in pixels. This value must be greater than 0.
pixelsHigh: The height of the image in pixels. This value must be greater than 0.
bitsPerSample: 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. bps should be one of these values: 1, 2, 4, 8, 12, or 16.
samplesPerPixel: The number of data components, or samples per pixel. This value 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 grayscale image that lacks a coverage component would have an spp of 1.
hasAlpha: True if one of the components counted in the number of samples per pixel (spp) is a coverage (alpha) component, and false if there is no coverage component. If true, the color components in the bitmap data must be premultiplied with their coverage component.
colorSpaceName: A string constant that indicates how data values are to be interpreted. It should be one of the following values: NSCalibratedWhiteColorSpace, NSCalibratedBlackColorSpace, NSCalibratedRGBColorSpace, NSDeviceWhiteColorSpace, NSDeviceBlackColorSpace, NSDeviceRGBColorSpace, NSDeviceCMYKColorSpace, NSNamedColorSpace or NSCustomColorSpace. (see NSColorSpaceMBS)
If bps is 12, you cannot specify the monochrome color space.
bytesPerRow: 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 you pass in a rowBytes value of 0, the bitmap data allocated may be padded to fall on long word or larger boundaries for performance. If your code wants to advance row by row, use bytesPerRow and do not assume the data is packed. Passing in a non-zero value allows you to specify exact row advances.
bitsPerPixel: This integer value informs NSBitmapImageRep 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. NSBitmapImageRep supports only a limited number of pixelBits values (other than the default): for RGB images with 4 bps, pixelBits may be 16; for RGB images with 8 bps, pixelBits may be 32. The legal values for pixelBits are system dependent.
If you specify 0 for this parameter, the object interprets the number of bits per pixel using the values in the bps and spp parameters, as described in the preceding paragraph, without any meaningless bits.

On success the handle property is not zero.

You can add several NSBitmapImageRepMBS to NSImage to make a multi page tiff file.
To make a 300 dpi image, the size of the NSImage must be smaller than the size of the bitmap inside by factor 72/300.

See also:

NSBitmapImageRepMBS.GIFRepresentation(properties as dictionary = nil) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the bitmap as gif data.

NSBitmapImageRepMBS.JPEGRepresentation(properties as dictionary = nil) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the bitmap as jpeg data.

NSBitmapImageRepMBS.PNGRepresentation(properties as dictionary = nil) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the bitmap as PNG data.

NSBitmapImageRepMBS.TIFFRepresentation as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a TIFF representation of the receiver.

This method invokes TIFFRepresentationUsingCompression using the stored compression type and factor retrieved from the initial image data or changed using setCompression. If the stored compression type isn't supported for writing TIFF data (for example, NSTIFFCompressionNEXT), the stored compression is changed to NSTIFFCompressionNone before invoking TIFFRepresentationUsingCompression. receiver, using the compression that's returned by getCompression (if applicable).

If a problem is encountered during generation of the TIFF, TIFFRepresentation raises an NSTIFFException or an NSBadBitmapParametersException.

See also:

NSBitmapImageRepMBS.TIFFRepresentation(properties as dictionary = nil) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the bitmap as tiff data.

See also:

NSBitmapImageRepMBS.valueForProperty(key as string) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Drawing MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The value for the specified property.

Value can be nil.
(Read and Write computed property)

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...