image

1枚のイメージを表すクラス。画像の操作に使用する。


xshade
image

メソッド一覧

convert_bump_to_normalmap 画像がバンプマップの濃淡画像の場合に、法線マップに変換する
convert_rgb_to_grayscale RGB画像をグレイスケール変換する
copy_to_clipboard イメージをクリップボードにコピーする
create_window イメージを表示するウインドウを作成する
difference イメージの差分を作成する
duplicate イメージを複製する
equal イメージを比較し、等しいかどうかを返す
file_exists 外部参照されたファイルが存在しているかどうかを返す
get_pixel イメージの指定したピクセルの色を返す
get_pixel_rgba イメージの指定したピクセルの色を返す
save イメージをファイルに保存する
set_pixel イメージの指定したピクセルに色を設定する
set_pixel_rgba イメージの指定したピクセルに色を設定する
set_real_color イメージの指定したピクセルに色を設定する
set_z 指定したピクセルのZ値を設定する
similar イメージを比較し、似ているかどうかを返す
update 外部参照されたファイルを読み込み、イメージを更新する

プロパティ一覧

bounds イメージの範囲の矩形
external_reference 外部参照形状かどうか
has_image イメージを実際に持っているかどうか
has_real_color 64bits以上の色深度のイメージかどうか
has_z Z値を持っているかどうか
is_fake フェイクかどうか
is_movie 動画ファイルかどうか
offset イメージのオフセット
path 読み込みイメージの読み込み先のパス
pixel_depth ピクセルの色深度
pixel_format イメージのピクセルフォーマット
shift マッピング時のシフト距離
size イメージのサイズ
total_frames 動画ファイルの全フレーム数




xshade.scene().rendering.image(レンダリングイメージの取得) のように、イメージを取得して使用する。

メソッド詳細

convert_bump_to_normalmap

画像がバンプマップの濃淡画像の場合に、法線マップに変換する。カラー画像は内部的にグレースケールに変換されてから法線マップに変換される。
引数 :
  weight : 荷重。値が小さいほど凸凹が小さくなる。

xshade.scene().rendering.image.convert_bump_to_normalmap(1.0)

convert_rgb_to_grayscale

RGB画像をグレイスケール変換する

xshade.scene().rendering.image.convert_rgb_to_grayscale()

copy_to_clipboard

イメージをクリップボードにコピーする。

xshade.scene().rendering.image.copy_to_clipboard()

create_window

イメージを表示するウインドウを作成する。
戻り値 :
  windowオブジェクト
引数 :
  string : ウインドウのタイトル、省略可能

xshade.scene().rendering.image.create_window()

difference

イメージの差分を作成する。
戻り値 :
  imageオブジェクト
引数 :
  image : imageオブジェクト
参照 :
  equal
  similar

#レンダリングイメージを別イメージと比較、結果をウインドウに表示する
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

イメージを複製する。
戻り値 :
  imageオブジェクト
引数 :
  size : イメージのサイズ : 0を渡すとサイズを変更しない
引数 :
  bool : size で指定したサイズにフィットするか
引数 :
  int : 色深度(32, 64, 128bits)

#レンダリングイメージを変形させて新規ウインドウで開く
img = xshade.scene().rendering.image.duplicate((500, 100), True, 32)
img.create_window()

equal

イメージを比較し、等しいかどうかを返す。
戻り値 :
  bool
引数 :
  image : imageオブジェクト
参照 :
  difference
  similar

#レンダリングイメージと別イメージが等しいかどうか出力する
img_a = xshade.scene().rendering.image
print img_a.equal(img_b)

file_exists

外部参照されたファイルが存在しているかどうかを返す。
戻り値 :
  bool

#選択したマスターイメージに参照されたimage_objectが存在するかどうか出力する
print xshade.scene().active_shape().image.file_exists()

get_pixel

イメージの指定したピクセルの色を返す。
戻り値 :
  rgb
引数 :
  int : X座標
引数 :
  int : Y座標
参照 :
  set_pixel

print xshade.scene().active_shape().image.get_pixel(10,10)

get_pixel_rgba

イメージの指定したピクセルの色を返す。
戻り値 :
  rgba
引数 :
  int : X座標
引数 :
  int : Y座標
参照 :
  set_pixel_rgba

print xshade.scene().active_shape().image.get_pixel_rgba(10,10)

save

イメージをファイルに保存する。
引数 :
  file_path
画像形式は拡張子で指定 :

■MacOSX
PNG *.png
TIFF *.tif, *.tiff
Windows Bitmap *.bmp
JPEG *.jpg, *.jpeg
GIF *.gif
OpenEXR *.exr
Targa(32bit版のみ) *.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
#レンダリングイメージをpsd形式で保存する
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.psd|psd')
xshade.scene().rendering.image.save(file_path)

set_pixel

イメージの指定したピクセルに色を設定する。
引数 :
  int : X座標
引数 :
  int : Y座標
引数 :
  rgb : (32bits/チャンネル RGB HDR)
参照 :
  get_pixel
set_real_colorと同じ。Shade7まで別メソッドだったが、現在は内部で連動している。

#Y20の位置にX0からX99まで赤のラインを描画する
#イメージウインドウを更新するまで反映されない
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

イメージの指定したピクセルに色を設定する。
引数 :
  int : X座標
引数 :
  int : Y座標
引数 :
  rgba :
参照 :
  get_pixel_rgba

xshade.scene().active_shape().image.set_pixel_rgba(10,10,(1,1,1,1))

set_real_color

イメージの指定したピクセルに色を設定する。
引数 :
  int : X座標
引数 :
  int : Y座標
引数 :
  rgb : (32bits/チャンネル RGB HDR)
アルファチャンネルには1.0(不透明)が設定される
set_pixelと同じ。Shade7まで別メソッドだったが、現在は内部で連動している。

#Y20の位置にX0からX99まで赤のラインを設定し、ウインドウで開く
#イメージウインドウを再表示すると反映される
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

指定したピクセルのZ値を設定する
引数 :
  int : X座標
引数 :
  int : Y座標
引数 :
  float : Z値

xshade.scene().rendering.image.set_z()

similar

イメージを比較し、似ているかどうかを返す。
戻り値 :
  bool
引数 :
  image : imageオブジェクト

#レンダリングイメージと別イメージが似ているかどうか出力する
print xshade.scene().rendering.image.similar(image_b)

update

外部参照されたファイルを読み込み、イメージを更新する。
戻り値 :
  bool
引数 :
  frame : 数値 : 読み込みを行うフレーム(動画ファイルの場合)

#外部参照しているイメージオブジェクトを更新する
image_object.update()

プロパティ詳細

bounds

イメージの範囲の矩形。

  • 取得
  • 設定

型 :
  rectangle
参照 :
  size

#レンダリングイメージの範囲の矩形を出力する
print xshade.scene().rendering.image.bounds

external_reference

外部参照形状かどうか。

  • 取得
  • 設定

型 :
  bool

print xshade.scene().active_shape().image.external_reference

has_image

イメージを実際に持っているかどうか。

  • 取得
  • 設定

型 :
  bool : False : empty_image()などの空イメージ

#イメージオブジェクトがイメージを持っているかどうか出力する
print image_object.has_image

has_real_color

64bits以上の色深度のイメージかどうか。

  • 取得
  • 設定

型 :
  bool : True : レンダリング設定で色深度を64bits以上に設定したレンダリングイメージまたは、HDRI対応の画像形式から読み込んだイメージ

#レンダリングイメージが64bits以上の色深度のイメージかどうかを出力する
print xshade.scene().rendering.image.has_real_color

has_z

Z値を持っているかどうか。

  • 取得
  • 設定

型 :
  bool

#レンダリングイメージがZ値を持っているかどうかを出力する
print xshade.scene().rendering.image.has_z

is_fake

フェイクかどうか。

  • 取得
  • 設定

型 :
  bool
フェイク:サイズ、色深度などの情報のみを持ち、内部的に使用されるダミーのイメージ。

#レンダリングイメージがフェイクかどうかを出力する
print xshade.scene().rendering.image.is_fake

is_movie

動画ファイルかどうか。

  • 取得
  • 設定

型 :
  bool

#レンダリングイメージが動画ファイルかどうかを出力する
print xshade.scene().rendering.image.is_movie

offset

イメージのオフセット。

  • 取得
  • 設定

型 :
  size

#レンダリングイメージのオフセットを出力する
print xshade.scene().rendering.image.offset

path

読み込みイメージの読み込み先のパス。

  • 取得
  • 設定

型 :
  file_path

print xshade.scene().active_shape().image.path

pixel_depth

ピクセルの色深度。

  • 取得
  • 設定

型 :
  int

#レンダリングイメージのピクセルの色深度を出力する
print xshade.scene().rendering.image.pixel_depth

pixel_format

イメージのピクセルフォーマット。

  • 取得
  • 設定

型 :
  int : 0:(u1_8)、1:(u1_32)、2:(u4_32)、3:(f1_16)、4:(f1_32)、5:(f4_64)、6:(f4_128)
「u」は「符号なし整数型」、「f」は「浮動小数」
カッコ内は([Type][Channel数]_[Bits])を表す。
例)(f4_128)→1ピクセル=128ビット浮動小数×4

print xshade.scene().active_shape().image.pixel_format

shift

マッピング時のシフト距離。

  • 取得
  • 設定

型 :
  float2 : 0.0~1.0の範囲内

#レンダリングイメージのマッピング時のシフト距離を出力する
print xshade.scene().rendering.image.shift

size

イメージのサイズ。

  • 取得
  • 設定

型 :
  size : イメージのサイズ(縦横のピクセル数)
参照 :
  bounds

#レンダリングイメージのサイズを出力する
print xshade.scene().rendering.image.size

total_frames

動画ファイルの全フレーム数。

  • 取得
  • 設定

型 :
  int

#動画ファイルの全フレーム数を出力する
print xshade.scene().active_shape().image.total_frames