Class which expresses a single image. Used for image operations.
xshade |
↑ |
image |
convert_bump_to_normalmap | If the image is a bump map grayscale image, converts to a normal map |
convert_rgb_to_grayscale | Converts an RGB image to grayscale |
copy_to_clipboard | Copies the image to the clipboard |
create_window | Creates a window to display the image |
difference | Creates the difference of the images |
duplicate | Duplicates the image |
equal | Compares the images, and returns whether or not they are equal |
file_exists | Returns whether or not the externally-referenced file exists |
get_pixel | Returns the color of the specified pixel of the image |
get_pixel_rgba | Returns the color of the specified pixel of the image |
save | Saves the image to a file |
set_pixel | Sets the color of the specified pixel of the image |
set_pixel_rgba | Sets the color of the specified pixel of the image |
set_real_color | Sets the color of the specified pixel of the image |
set_z | Sets the Z Depth of the specified pixel |
similar | Compares the images, and returns whether or not they are similar |
update | Loads an externally-referenced file, and updates the image |
bounds | The rectangle of the image area |
external_reference | Whether it is an external reference object or not |
has_image | Whether it actually has an image or not |
has_real_color | Whether the image has a color depth of 64 bits or higher or not |
has_z | Whether it has a Z Depth or not |
is_fake | Whether it is fake or not |
is_movie | Whether it is a movie file or not |
offset | The image offset |
path | The path of a loaded image |
pixel_depth | The pixel color depth |
pixel_format | The pixel format of the image |
shift | The shift distance when mapping |
size | The image size |
total_frames | The total number of frames of a movie file |
Used after getting the rendered image with a method such as xshade.scene().rendering.image.
convert_bump_to_normalmap
If the image is a bump map grayscale image, converts to a normal map. Color images are first converted to grayscale images internally and then converted to normal maps.
Arguments :
weight : The weight. Smaller values indicate smaller bumps.
xshade.scene().rendering.image.convert_bump_to_normalmap(1.0)
convert_rgb_to_grayscale
Converts an RGB image to grayscale
xshade.scene().rendering.image.convert_rgb_to_grayscale()
copy_to_clipboard
Copies the image to the clipboard.
xshade.scene().rendering.image.copy_to_clipboard()
create_window
Creates a window to display the image.
Return value :
window object
Arguments :
string : The window title. Optional.
xshade.scene().rendering.image.create_window()
difference
Creates the difference of the images.
Return value :
image object
Arguments :
image : image object
See also :
equal
similar
#Compare the rendered image to a different image, and display the results in a window
img_a = xshade.scene().rendering.image
img_b = xshade.scene().active_shape().image
img_c = img_a.difference(img_b)
img_c.create_window('difference')
duplicate
Duplicates the image.
Return value :
image object
Arguments :
size : The image size : If 0 is passed, the size does not change.
Arguments :
bool : Whether the image fits the size specified by "size"
Arguments :
int : The color depth (32, 64, 128 bits)
#Morph the rendered image and open in a new window
img = xshade.scene().rendering.image.duplicate((500, 100), True, 32)
img.create_window()
equal
Compares the images, and returns whether or not they are equal.
Return value :
bool
Arguments :
image : image object
See also :
difference
similar
#Output whether or not the rendered image is equal to a different image
img_a = xshade.scene().rendering.image
print img_a.equal(img_b)
file_exists
Returns whether or not the externally-referenced file exists.
Return value :
bool
#Output whether or not image_object referenced in the selected master image exists
print xshade.scene().active_shape().image.file_exists()
get_pixel
Returns the color of the specified pixel of the image.
Return value :
rgb
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
See also :
set_pixel
print xshade.scene().active_shape().image.get_pixel(10,10)
get_pixel_rgba
Returns the color of the specified pixel of the image.
Return value :
rgba
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
See also :
set_pixel_rgba
print xshade.scene().active_shape().image.get_pixel_rgba(10,10)
save
Saves the image to a file.
Arguments :
file_path
Specify the image format via the extension :
Mac OSX | |
---|---|
PNG | *.png |
TIFF | *.tif, *.tiff |
Windows Bitmap | *.bmp |
JPEG | *.jpg, *.jpeg |
GIF | *.gif |
OpenEXR | *.exr |
Targa (32 bit version only) | *.tga |
HDR | *.hdr |
PFM | *.pfm |
Flash | *.swf |
Photoshop | *.psd |
Windows | |
---|---|
BMP | *.bmp, *.dib, *.rle |
JPEG | *.jpg, *.jpeg, *.jpe, *.jfif, *.jif |
GIF | *.gif |
TIFF | *.tif, *.tiff |
PNG | *.png |
OpenEXR | *.exr |
Targa | *.tga |
TARGA | *.targa |
HDR | *.hdr |
PFM | *.pfm |
Flash | *.swf |
Photoshop | *.psd |
#Save rendered image in psd format
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.psd|psd')
xshade.scene().rendering.image.save(file_path)
set_pixel
Sets the color of the specified pixel of the image.
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
Arguments :
rgb : (32 bit per channel RGB HDR)
See also :
get_pixel
Same as set_real_color. These were different methods up through Shade 7, but are currently linked internally.
#Draw a red line at position Y20 from X0 to X99 #Not reflected until the Image Window is updated for i in xrange(100): xshade.scene().rendering.image.set_pixel(i,20,(1.0, 0.0, 0.0)) xshade.image_view().update()
set_pixel_rgba
Sets the color of the specified pixel of the image.
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
Arguments :
rgba :
See also :
get_pixel_rgba
xshade.scene().active_shape().image.set_pixel_rgba(10,10,(1,1,1,1))
set_real_color
Sets the color of the specified pixel of the image.
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
Arguments :
rgb : (32 bit per channel RGB HDR)
The alpha channel is set to 1.0 (opaque).
Same as set_pixel. These were different methods up through Shade 7, but are currently linked internally.
#Set a red line at position Y20 from X0 to X99, and open in a new window #Reflected once the Image Window is redrawn for i in xrange(100): xshade.scene().rendering.image.set_real_color(i,20,(1.0, 0.0, 0.0)) xshade.scene().rendering.image.create_window()
set_z
Sets the Z Depth of the specified pixel.
Arguments :
int : The X coordinate
Arguments :
int : The Y coordinate
Arguments :
float : The Z Depth
xshade.scene().rendering.image.set_z()
similar
Compares the images, and returns whether or not they are similar.
Return value :
bool
Arguments :
image : image object
#Output whether or not the rendered image is similar to a different image
print xshade.scene().rendering.image.similar(image_b)
update
Loads an externally-referenced file, and updates the image.
Return value :
bool
Arguments :
frame : number : The frame in which to load (in the case of a movie file)
#Update an externally-referenced image object
image_object.update()
bounds
#Output the rectangle of the rendered image area
print xshade.scene().rendering.image.bounds
external_reference
Whether it is an external reference object or not.
Type :
bool
print xshade.scene().active_shape().image.external_reference
has_image
Whether it actually has an image or not.
Type :
bool : False : an empty image, such as empty_image()
#Output whether or not the image object has an image
print image_object.has_image
has_real_color
Whether the image has a color depth of 64 bits or higher or not.
Type :
bool : True : A rendered image with the color depth set to 64 bits or higher in the Rendering Settings, or an image loaded from an HDRI-supported format
#Output whether or not the rendered image has a color depth of 64 bits or higher
print xshade.scene().rendering.image.has_real_color
has_z
Whether it has a Z Depth or not.
Type :
bool
#Output whether or not the rendered image has a Z Depth
print xshade.scene().rendering.image.has_z
is_fake
Whether it is fake or not.
Type :
bool
A fake image is a dummy image used internally, which only has size, color depth, and so on.
#Output whether or not the rendered image is fake
print xshade.scene().rendering.image.is_fake
is_movie
Whether it is a movie file or not.
Type :
bool
#Output whether or not the rendered image is a movie file
print xshade.scene().rendering.image.is_movie
offset
The image offset.
Type :
size
#Output the offset of the rendered image
print xshade.scene().rendering.image.offset
path
The path of a loaded image.
Type :
file_path
print xshade.scene().active_shape().image.path
pixel_depth
The pixel color depth.
Type :
int
#Output the pixel color depth of the rendered image
print xshade.scene().rendering.image.pixel_depth
pixel_format
The pixel format of the image.
Type :
int : 0: (u1_8), 1: (u1_32), 2: (u4_32), 3: (f1_16), 4: (f1_32), 5: (f4_64), 6: (f4_128)
"u" is an unsigned integer; "f" is a floating point.
The parantheses include: ([Type][Channel]_[Bits]).
Example: (f4_128) means that each pixel has four 128-bit floating point numbers
print xshade.scene().active_shape().image.pixel_format
shift
The shift distance when mapping.
Type :
float2 : Between 0.0 and 1.0
#Output the shift distance when mapping the rendered image
print xshade.scene().rendering.image.shift
size
The image size.
Type :
size : The image size (the number of pixels horizontally and vertically)
See also :
bounds
#Output the rendered image size
print xshade.scene().rendering.image.size
total_frames
The total number of frames of a movie file.
Type :
int
#Output the total number of frames of the movie file
print xshade.scene().active_shape().image.total_frames