Class: Fox::FXBitmap

Inherits:
FXDrawable show all
Defined in:
rdoc-sources/FXBitmap.rb

Overview

A bitmap is a rectangular array of pixels. It supports two representations of these pixels: a client-side pixel buffer, and a server-side pixmap which is stored in an organization directly compatible with the screen, for fast drawing onto the device. The server-side representation is not directly accessible from the current process at it lives in the process of the X server or GDI (on Microsoft Windows). The client-side pixel array is of size height x (width+7)/8 bytes; in other words, 8 pixels packed into a single byte, starting with bit zero on the left.

Image rendering hints

BITMAP_KEEP

Keep pixel data in client

BITMAP_OWNED

Pixel data is owned by image

BITMAP_SHMI

Using shared memory image

BITMAP_SHMP

Using shared memory pixmap

Instance Attribute Summary

Attributes inherited from FXDrawable

#height, #visual, #width

Attributes inherited from FXId

#app, #userData, #xid

Instance Method Summary collapse

Methods inherited from FXId

#create, #created?, #destroy, #detach, #runOnUiThread

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(app, pixels = nil, opts = 0, width = 1, height = 1) ⇒ FXBitmap

Return an initialized FXBitmap instance. If a client-side pixel buffer (the pixels argument) has been specified, the bitmap does not own that pixel buffer unless the BITMAP_OWNED flag is set. If the BITMAP_OWNED flag is set, but a nil value for pixels is passed in, a pixel buffer will be automatically created and will be owned by the bitmap. The flags BITMAP_SHMI and BITMAP_SHMP may be specified for large bitmaps to instruct #render to use shared memory to communicate with the server.



33
34
# File 'rdoc-sources/FXBitmap.rb', line 33

def initialize(app, pixels=nil, opts=0, width=1, height=1) # :yields: theBitmap
end

Instance Method Details

#crop(x, y, w, h, color = false) ⇒ Object

Crop bitmap to given rectangle; this calls #resize to adjust the client and server side representations. The new bitmap may be smaller or larger than the old one; blank areas are filled with color. There must be at least one pixel of overlap between the old and the new bitmap.



110
# File 'rdoc-sources/FXBitmap.rb', line 110

def crop(x, y, w, h, color=false); end

#dataObject



21
# File 'rdoc-sources/FXBitmap.rb', line 21

alias data getData

#fill(color) ⇒ Object

Fill bitmap with uniform value



113
# File 'rdoc-sources/FXBitmap.rb', line 113

def fill(color); end

#getDataObject

Return the pixel data.



53
# File 'rdoc-sources/FXBitmap.rb', line 53

def getData(); end

#getPixel(x, y) ⇒ Object

Get pixel state (either true or false) at (x, y)



87
# File 'rdoc-sources/FXBitmap.rb', line 87

def getPixel(x, y) ; end

#loadPixels(stream) ⇒ Object

Load pixel data from a stream



84
# File 'rdoc-sources/FXBitmap.rb', line 84

def loadPixels(stream); end

#mirror(horizontal, vertical) ⇒ Object

Mirror the bitmap horizontally and/or vertically



99
# File 'rdoc-sources/FXBitmap.rb', line 99

def mirror(horizontal, vertical); end

#optionsObject

Return the option flags.



56
# File 'rdoc-sources/FXBitmap.rb', line 56

def options; end

#options=(opts) ⇒ Object

Set the options.



59
# File 'rdoc-sources/FXBitmap.rb', line 59

def options=(opts); end

#releaseObject

Release the client-side pixels buffer and free it if it was owned. If it is not owned, the image just forgets about the buffer.



71
# File 'rdoc-sources/FXBitmap.rb', line 71

def release(); end

#renderObject

Render the server-side representation of the bitmap from the client-side pixels.



65
# File 'rdoc-sources/FXBitmap.rb', line 65

def render() ; end

#resize(w, h) ⇒ Object

Resize both client-side and server-side representations (if any) to the given width and height. The new representations typically contain garbage after this operation and need to be re-filled.



78
# File 'rdoc-sources/FXBitmap.rb', line 78

def resize(w, h); end

#restoreObject

Retrieve pixels from the server-side bitmap.



62
# File 'rdoc-sources/FXBitmap.rb', line 62

def restore; end

#rotate(degrees) ⇒ Object

Rotate bitmap by degrees degrees (counter-clockwise)



102
# File 'rdoc-sources/FXBitmap.rb', line 102

def rotate(degrees); end

#savePixels(stream) ⇒ Object

Save pixel data only



81
# File 'rdoc-sources/FXBitmap.rb', line 81

def savePixels(stream); end

#scale(w, h) ⇒ Object

Rescale pixels image to the specified width and height; this calls #resize to adjust the client and server side representations.



96
# File 'rdoc-sources/FXBitmap.rb', line 96

def scale(w, h); end

#setData(pix, opts, w, h) ⇒ Object

Populate the bitmap with new pixel data of a new size; it will assume ownership of the pixel data if the BITMAP_OWNED option is passed in the opts. The size of the server- side representation of the image, if it exists, is adjusted but the contents are not updated; to update the server-side representation, call #render.



42
# File 'rdoc-sources/FXBitmap.rb', line 42

def setData(pix, opts=0); end

#setPixel(x, y, color) ⇒ Object

Change pixel at (x, y), where color is either true or false.



90
# File 'rdoc-sources/FXBitmap.rb', line 90

def setPixel(x, y, color) ; end