Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

NSImageMBS.addRepresentation(img as NSImageRepMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 8.4 Yes No No Yes, macOS only No
Function: Adds the specified image representation object to to the receiver.
Notes:
After invoking this method, you may need to explicitly set features of the new image representation, such as the size, number of colors, and so on. This is true particularly when the NSImage object has multiple image representations to choose from. See NSImageRep and its subclasses for the methods you use to complete initialization.

Any representation added by this method is retained by the receiver. Image representations cannot be shared among multiple NSImage objects.

Feedback, Comments & Corrections

NSImageMBS.BMPRepresentation as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The image as the binary data in a BMP file.
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p,p.Mask)

f=SpecialFolder.Desktop.Child("test.bmp")
b=f.CreateBinaryFile("")
b.Write img.BMPRepresentation
b.Close

f.Launch
Notes: BMP does not support masks.

Feedback, Comments & Corrections

NSImageMBS.BMPRepresentationMT as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 13.1 Yes No No Yes, macOS only No
Function: The image as the binary data in a BMP file.
Notes:
BMP does not support masks.
Must be called inside a Xojo (Real Studio) thread so time yields to main thread and you can keep the GUI running.

Feedback, Comments & Corrections

NSImageMBS.cancelIncrementalLoad
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Cancels the current download operation immediately, if the image is being incrementally loaded.
Notes: This call has no effect if the image is not loading.

Feedback, Comments & Corrections

NSImageMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The default constructor creating a dummy NSImage object.

See also:

Feedback, Comments & Corrections

NSImageMBS.Constructor(data as Memoryblock)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The data constructor calling initWithData internally.
Notes:
Calls initWithData.
On success the image is valid and the handle is not zero.

See also:

Feedback, Comments & Corrections

NSImageMBS.Constructor(file as folderitem)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The file constructor calling initWithContentsOfURL(file) internally.
Notes:
Calls initWithContentsOfURL.
On success the image is valid and the handle is not zero.

See also:

Feedback, Comments & Corrections

NSImageMBS.Constructor(image as Picture, mask as picture = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Creates a new NSImageMBS object based on the image data in a Realbasic picture.
Example:
dim img as new NSImageMBS(pict)
Notes:
Optional you can pass a picture with the mask. It is valid to use the mask property of the image for the second parameter.

With 11.3 plugins we are deprecating to pass a mask. The plugin prefers to simply take the mask or alpha channel of the picture itself.

On success the image is valid and the handle is not zero.
Calls initWithPicture.

See also:

Feedback, Comments & Corrections

NSImageMBS.Constructor(width as Double, height as Double)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The size constructor calling initWithSize internally.
Notes:
Calls initWithSize.
On success the image is valid and the handle is not zero.

See also:

Feedback, Comments & Corrections

NSImageMBS.CopyMask as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.5 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage in current size.
Example:
dim f as FolderItem
dim n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyMask
Notes:
Copies only the alpha channel as mask.

A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

Feedback, Comments & Corrections

NSImageMBS.CopyPicture(CGColorSpace as Variant = nil, BackgroundColor as NSColorMBS = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.5 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage in current size.
Example:
dim f as FolderItem
dim n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPicture // background is black
Notes:
A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

If BackgroundColor is not nil, the image is filled in background with this color and NSImage rendered on top of it.

Feedback, Comments & Corrections

NSImageMBS.CopyPictureRect(x as Integer, y as Integer, w as Integer, h as Integer, CGColorSpace as Variant = nil, BackgroundColor as NSColorMBS = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 13.2 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage from the given rectangle.
Example:
dim f as FolderItem
dim n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPicture // background is black
Notes:
A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

If BackgroundColor is not nil, the image is filled in background with this color and NSImage rendered on top of it.

Feedback, Comments & Corrections

NSImageMBS.CopyPictureWithAlpha as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 15.1 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage in current size.
Notes:
This is a function for Cocoa target which returns picture with alpha channel.
Returns nil on any error.

Feedback, Comments & Corrections

NSImageMBS.CopyPictureWithAlphaRect(x as Integer, y as Integer, w as Integer, h as Integer) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 15.1 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage in given rectangle.
Notes:
This is a function for Cocoa target which returns picture with alpha channel.
Returns nil on any error.

Feedback, Comments & Corrections

NSImageMBS.CopyPictureWithMask(CGColorSpace as Variant = nil) as picture
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.5 Yes No No Yes, macOS only No
Function: Copies the content of the NSImage in current size.
Example:
dim f as FolderItem
dim n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPictureWithMask
Notes:
Copies the picture and its mask.
This function is faster than CopyPicture and CopyMask combined as the picture is only copied one time to an internal buffer.

A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

Feedback, Comments & Corrections

NSImageMBS.DrawIntoCGContextAtPoint(cgcontext as Integer, x as Double, y as Double, sx as Double, sy as Double, SourceW as Double, SourceH as Double, operation as Integer, fraction as Double) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Draws the image.
Notes: Same as DrawIntoCGContextAtRect, but with a point instead of a rectangle.

Feedback, Comments & Corrections

NSImageMBS.DrawIntoCGContextAtRect(cgcontext as Integer, x as Double, y as Double, w as Double, h as Double, SourceX as Double, SourceY as Double, SourceW as Double, SourceH as Double, operation as Integer, fraction as Double) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Draws the image.
Example:
Function OpenAsNSimage(extends file as folderitem) As picture
dim width as Integer
dim height as Integer
dim c as NSImageMBS
dim g as CGPictureContextMBS

// load image from file
c=new NSImageMBS

// is that image valid?
if c.initWithContentsOfURL(file) then
Width=c.Width
height=c.Height

// create a drawing buffer to draw inside
g=new CGPictureContextMBS(width,height)

if g.Handle<>0 then // valid?

// now draw the image inside.
// you could scale or even apply transparency...
if c.DrawIntoCGContextAtRect(g.Handle, 0, 0, width, height, 0,0,width,height,2,1.0) then
// make a RB Picture from it
Return g.CopyPicture
end if
end if
end if
End Function
Notes:
Draws the image into a CGContext. You need to specify first the destination rectangle followed by the source rectangle.

fraction:
The opacity of the image, specified as a value from 0.0 to 1.0. Specifying a value of 0.0 draws the image as fully transparent while a value of 1.0 draws the image as fully opaque. Values greater than 1.0 are interpreted as 1.0.

operation codes:
NSCompositeClear = 0Transparent.
NSCompositeCopy = 1Source image.
NSCompositeSourceOver = 2Source image wherever source image is opaque, and destination image elsewhere.
NSCompositeSourceIn = 3Source image wherever both images are opaque, and transparent elsewhere.
NSCompositeSourceOut = 4Source image wherever source image is opaque but destination image is transparent, and transparent elsewhere.
NSCompositeSourceAtop = 5Source image wherever both images are opaque, destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere.
NSCompositeDestinationOver = 6Destination image wherever destination image is opaque, and source image elsewhere.
NSCompositeDestinationIn = 7Destination image wherever both images are opaque, and transparent elsewhere.
NSCompositeDestinationOut = 8Destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere.
NSCompositeDestinationAtop = 9Destination image wherever both images are opaque, source image wherever source image is opaque but destination image is transparent, and transparent elsewhere.
NSCompositeXOR = 10Exclusive OR of source and destination images.
NSCompositePlusDarker = 11Sum of source and destination images, with color values approaching 0 as a limit.
NSCompositeHighlight = 12Source image wherever source image is opaque, and destination image elsewhere.
NSCompositePlusLighter = 13Sum of source and destination images, with color values approaching 1 as a limit.

Returns true on success and false on failure.

Feedback, Comments & Corrections

NSImageMBS.GIFRepresentation as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: The image as the binary data in a GIF file.
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p,p.Mask)

f=SpecialFolder.Desktop.Child("test.gif")
b=f.CreateBinaryFile("")
b.Write img.GIFRepresentation
b.Close

f.Launch
Notes: GIF does support masks in a limited way.

Feedback, Comments & Corrections

NSImageMBS.GIFRepresentationMT as Memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 13.1 Yes No No Yes, macOS only No
Function: The image as the binary data in a GIF file.
Notes:
GIF does support masks in a limited way.
Must be called inside a Xojo (Real Studio) thread so time yields to main thread and you can keep the GUI running.

Feedback, Comments & Corrections

NSImageMBS.imageByFadingToFraction(fraction as Double) as NSImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Returns an image with a mask faded to the given percentage
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p)

img=img.imageByFadingToFraction(0.1)

f=SpecialFolder.Desktop.Child("test.png")
b=f.CreateBinaryFile("")
b.Write img.PNGRepresentation
b.Close

f.Launch
Notes: Returns nil on failure.

Feedback, Comments & Corrections

NSImageMBS.imageByScalingToSize(width as Double, height as Double) as NSImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Scales image to the new size.
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p)

img=img.imageByScalingToSize(200,200)

f=SpecialFolder.Desktop.Child("test.png")
b=f.CreateBinaryFile("")
b.Write img.PNGRepresentation
b.Close

f.Launch
Notes:
Returns nil on failure.
Internally creates a copy of the image.

See also:

Feedback, Comments & Corrections

NSImageMBS.imageByScalingToSize(width as Double, height as Double, fraction as Double) as NSImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Scales image to the new size with given fading.
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p)

img=img.imageByScalingToSize(200,200,0.5)

f=SpecialFolder.Desktop.Child("test.png")
b=f.CreateBinaryFile("")
b.Write img.PNGRepresentation
b.Close

f.Launch
Notes:
Returns nil on failure.
Internally creates a copy of the image.

See also:

Feedback, Comments & Corrections

NSImageMBS.imageByScalingToSize(width as Double, height as Double, fraction as Double, flip as boolean, proportionally as boolean) as NSImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Scales image to the new size with given fading fraction.
Example:
dim img as NSImageMBS
dim p as Picture
dim f as FolderItem
dim b as BinaryStream

p=NewPicture(100,100,32)
p.Graphics.ForeColor=&cFF0000
p.Graphics.FillOval 0,0,100,100
Backdrop=p
img=new NSImageMBS(p)

img=img.imageByScalingToSize(200,200)

f=SpecialFolder.Desktop.Child("test.png")
b=f.CreateBinaryFile("")
b.Write img.PNGRepresentation
b.Close

f.Launch
Notes:
Returns nil on failure.
The image can be flipped vertically with the flip property.
Internally creates a copy of the image.

See also:

Feedback, Comments & Corrections

NSImageMBS.initWithContentsOfURL(file as folderitem) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes and returns an NSImage instance with the contents of the specified folderitem.
Notes: Returns true on success and false on failure.

See also:

Feedback, Comments & Corrections

NSImageMBS.initWithContentsOfURL(url as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes and returns an NSImage instance with the contents of the specified URL.
Notes: Returns true on success and false on failure.

See also:

Feedback, Comments & Corrections

NSImageMBS.initWithData(data as Memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes and with the contents of the specified data in the string.
Notes: Returns true on success and false on failure.

Feedback, Comments & Corrections

NSImageMBS.initWithDataIgnoringOrientation(data as Memoryblock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Initializes and returns an NSImage instance with the contents of the specified memoryblock, ignoring the EXIF orientation tags.
Notes:
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the specified data object.
Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

NSImageMBS.initWithIconRef(IconHandle as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Initializes the image object with a Carbon-style icon resource.
Notes:
IconHandle: A reference to a Carbon icon resource (IconRef).

Creates one or more bitmap image representations, one for each size icon contained in the IconRef data structure. This initialization method automatically retains the data in the iconRef parameter and loads the bitmaps from that data file lazily.
Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

NSImageMBS.initWithPasteboard as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Drawing MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Initializes an NSImage instance with data from the pasteboard.
Notes: The specified pasteboard should contain a type supported by one of the registered NSImageRep subclasses. Table 1 lists the default pasteboard types and file extensions for several NSImageRep subclasses.

Feedback, Comments & Corrections

Next items

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




Links
MBS Xojo PDF Plugins