Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Image.py « doc « api2_2x « python « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e376b11c4fa60d3b94f3b0aef27e85d47babda2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# Blender.Image module and the Image PyType object

"""
The Blender.Image submodule.

Image
=====

B{New}: L{Image.clampX}, L{Image.clampY}.

This module provides access to B{Image} objects in Blender.

Example::
	import Blender
	from Blender import Image
	#
	image = Image.Load("/path/to/my/image.png")    # load an image file
	print "Image from", image.getFilename(),
	print "loaded to obj", image.getName())
	image.setXRep(4)                               # set x tiling factor
	image.setYRep(2)                               # set y tiling factor
	print "All Images available now:", Image.Get()

@type Sources: readonly dictionary
@var Sources: The available Image Source.
		- STILL: Single image file
		- MOVIE: Movie file
		- SEQUENCE: Multiple image files, as sequence
		- GENERATED: Generated image
"""

def Load (filename):
	"""
	Load the image called 'filename' into an Image object.
	@type filename: string
	@param filename: The full path to the image file.
	@rtype:  Blender Image
	@return: A Blender Image object with the data from I{filename}.
	"""

def New (name, width, height, depth):
	"""
	Create a new Image object.
	@type name: string
	@param name: The name of the new Image object.
	@type width: int
	@param width: The width of the new Image object, between 1 and 5000.
	@type height: int
	@param height: The height of the new Image object, between 1 and 5000.
	@type depth: int
	@param depth: The color depth of the new Image object. (32:RGBA 8bit channels, 128:RGBA 32bit high dynamic range float channels).
	@rtype: Blender Image
	@return: A new Blender Image object.
	"""

def Get (name = None):
	"""
	Get the Image object(s) from Blender.
	@type name: string
	@param name: The name of the Image object.
	@rtype: Blender Image or a list of Blender Images
	@return: It depends on the I{name} parameter:
			- (name): The Image object called I{name}, None if not found;
			- (): A list with all Image objects in the current scene.
	"""

def GetCurrent ():
	"""
	Get the currently displayed Image from Blenders UV/Image window.
	When multiple images are displayed, the last active UV/Image windows image is used.
	@rtype: Blender Image
	@return: The Current Blender Image, If there is no current image it returns None.
	"""

from IDProp import IDGroup, IDArray
class Image:
	"""
	The Image object
	================
		This object gives access to Images in Blender.
	@ivar filename: The filename (path) to the image file loaded into this Image
		 object.
	@type filename: string
	@ivar size: The [width, height] dimensions of the image (in pixels).
	@type size: list
	@ivar depth: The pixel depth of the image, read only. [8, 16, 18, 24, 32, 128 (for 32bit float color channels)]
	@type depth: int
	@ivar xrep: Texture tiling: the number of repetitions in the x (horizontal)
		 axis. [1, 16].
	@ivar yrep: Texture tiling: the number of repetitions in the y (vertical)
		 axis [1, 16].
	@type xrep: int 
	@type yrep: int 
	@ivar start: Texture's animation start frame [0, 128].
	@type start: int
	@ivar end: Texture's animation end frame [0, 128].
	@type end: int
	@ivar speed: Texture's animation speed [1, 100].
	@type speed: int
	@ivar packed: True when the Texture is packed (readonly).
	@type packed: boolean
	@ivar has_data: True when the image has pixel data (readonly).
	@type has_data: boolean
	@ivar fields: enable or disable the fields option for this image.
	@type fields: boolean
	@ivar fields_odd: enable or disable the odd fields option for this image.
	@type fields_odd: boolean
	@ivar antialias: enable or disable the antialias option for this image.
	@type antialias: boolean
	@ivar premul: premultiply alpha toggle.
	@type premul: boolean
	@ivar bindcode: Texture's bind code (readonly).
	@type bindcode: int
	@ivar source: Image source type.  See L{the Sources dictionary<Sources>} .
	@type source: int
	@ivar clampX: When true the image will not tile horizontally.
	@type clampX: bool
	@ivar clampY: When true the image will not tile vertically.
	@type clampY: bool
	"""

	def getName():
		"""
		Get the name of this Image object.
		@rtype: string
		"""

	def getFilename():
		"""
		Get the filename of the image file loaded into this Image object.
		@rtype: string
		"""

	def getSize():
		"""
		Get the [width, height] dimensions (in pixels) of this image.
		@rtype: list of 2 ints
		"""

	def getDepth():
		"""
		Get the pixel depth of this image. [8,16,24,32,128 for 32bit float images]
		@rtype: int
		"""

	def getPixelHDR(x, y):
		"""
		Get the the colors of the current pixel in the form [r,g,b,a].
		For float image types, returned values can be greater then the useual [0.0, 1.0] range.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@returns: [ r, g, b, a]
		@rtype: list of 4 floats
		@type x: int
		@type y: int
		@param x:  the x coordinate of pixel.
		@param y:  the y coordinate of pixel.  
		"""
		
	def getPixelF(x, y):
		"""
		Get the the colors of the current pixel in the form [r,g,b,a].
		Returned values are floats normalized to 0.0 - 1.0.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@returns: [ r, g, b, a]
		@rtype: list of 4 floats
		@type x: int
		@type y: int
		@param x:  the x coordinate of pixel.
		@param y:  the y coordinate of pixel.  
		"""
		
	def getPixelI(x, y):
		"""
		Get the the colors of the current pixel in the form [r,g,b,a].
		Returned values are ints normalized to 0 - 255.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@returns: [ r, g, b, a]
		@rtype: list of 4 ints
		@type x: int
		@type y: int
		@param x:  the x coordinate of pixel.
		@param y:  the y coordinate of pixel.  
		"""

	def getMaxXY():
		"""
		Get the  x & y size for the image.  Image coordinates range from 0 to size-1.
		@returns: [x, y]
		@rtype: list of 2 ints
		"""

	def getMinXY():
		"""
		Get the x & y origin for the image. Image coordinates range from 0 to size-1.
		@returns: [x, y]
		@rtype: list of 2 ints
		"""

	def getXRep():
		"""
		Get the number of repetitions in the x (horizontal) axis for this Image.
		This is for texture tiling.
		@rtype: int
		"""

	def getYRep():
		"""
		Get the number of repetitions in the y (vertical) axis for this Image.
		This is for texture tiling.
		@rtype: int
		"""

	def getBindCode():
		"""
		Get the Image's bindcode.  This is for texture loading using BGL calls.
		See, for example, L{BGL.glBindTexture} and L{glLoad}.
		@rtype: int
		"""

	def getStart():
		"""
		Get the Image's start frame. Used for animated textures.
		@rtype: int
		"""

	def getEnd():
		"""
		Get the Image's end frame. Used for animated textures.
		@rtype: int
		"""

	def getSpeed():
		"""
		Get the Image's speed (fps). Used for animated textures.
		@rtype: int
		"""

	def reload():
		"""
		Reloads this image from the filesystem.  If used within a loop you need to
		redraw the Window to see the change in the image, e.g. with
		Window.RedrawAll().
		@warn: if the image file is corrupt or still being written, it will be
			replaced by a blank image in Blender, but no error will be returned.
		@returns: None
		"""

	def updateDisplay():
		"""
		Update the display image from the floating point buffer (if it exists)
		@returns: None
		"""

	def glLoad():
		"""
		Load this image's data into OpenGL texture memory, if it is not already
		loaded (image.bindcode is 0 if it is not loaded yet).
		@note: Usually you don't need to call this method.  It is only necessary
			if you want to draw textured objects in the Scripts window and the
			image's bind code is zero at that moment, otherwise Blender itself can
			take care of binding / unbinding textures.  Calling this method for an
			image with nonzero bind code simply returns the image's bind code value
			(see L{getBindCode}).
		@rtype: int
		@returns: the texture's bind code.
		"""

	def glFree():
		"""
		Delete this image's data from OpenGL texture memory, only (the image itself
		is not removed from Blender's memory).  Internally, glDeleteTextures (see
		L{BGL.glDeleteTextures}) is used, but this method also updates Blender's
		Image object so that its bind code is set to 0.  See also L{Image.glLoad},
		L{Image.getBindCode}.
		"""

	def setName(name):
		"""
		Set the name of this Image object.
		@type name: string
		@param name: The new name.
		"""

	def setFilename(name):
		"""
		Change the filename of this Image object.
		@type name: string
		@param name: The new full filename.
		@warn: use this with caution and note that the filename is truncated if
			larger than 160 characters.
		"""

	def setXRep(xrep):
		"""
		Texture tiling: set the number of x repetitions for this Image.
		@type xrep: int
		@param xrep: The new value in [1, 16].
		"""

	def setYRep(yrep):
		"""
		Texture tiling: set the number of y repetitions for this Image.
		@type yrep: int
		@param yrep: The new value in [1, 16].
		"""

	def setStart(start):
		"""
		Get the Image's start frame. Used for animated textures.
		@type start: int
		@param start: The new value in [0, 128].
		"""

	def setEnd(end):
		"""
		Set the Image's end frame. Used for animated textures.
		@type end: int
		@param end: The new value in [0, 128].
		"""

	def setSpeed(speed):
		"""
		Set the Image's speed (fps). Used for animated textures.
		@type speed: int
		@param speed: The new value in [1, 100].
		"""

	def setPixelHDR(x, y, (r, g, b,a )):
		"""
		Set the the colors of the current pixel in the form [r,g,b,a].
		For float image types, returned values can be greater then the useual [0.0, 1.0] range.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@type x: int
		@type y: int
		@type r: float
		@type g: float
		@type b: float
		@type a: float
		@returns: nothing
		@rtype: none
		"""
		
	def setPixelF(x, y, (r, g, b,a )):
		"""
		Set the the colors of the current pixel in the form [r,g,b,a].
		Color values must be floats in the range 0.0 - 1.0.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@type x: int
		@type y: int
		@type r: float
		@type g: float
		@type b: float
		@type a: float
		@returns: nothing
		@rtype: none
		"""
		
	def setPixelI(x, y, (r, g, b, a)):
		"""
		Set the the colors of the current pixel in the form [r,g,b,a].
		Color values must be ints in the range 0 - 255.
		Pixel coordinates are in the range from 0 to N-1.  See L{getMaxXY}
		@type x: int
		@type y: int
		@type r: int
		@type g: int
		@type b: int
		@type a: int
		@returns: nothing
		@rtype: none
		"""
		
	def save():
		"""
		Saves the current image to L{filename}
		@note: Saving to a directory that doent exist will raise an error.
		@note: Saving a packed image will make a unique (numbered) name if the file alredy exists. Remove the file first to be sure it will not be renamed.
		@returns: None
		"""
	
	def pack():
		"""
		Packs the image into the current blend file.
		
		Since 2.44 new images without valid filenames can be packed.
		
		If the image is alredy packed, it will be repacked.
		
		@returns: nothing
		@rtype: none
		"""

	def unpack(mode):
		"""
		Unpacks the image to the images filename.
		@param mode: One of the values in L{Blender.UnpackModes}.
		@note: An error will be raised if the image is not packed or the filename path does not exist.
		@returns: nothing
		@rtype: none
		@type mode: int
		"""
	def makeCurrent():
		"""
		Set the currently displayed Image from Blenders UV/Image window.
		When multiple images are displayed, the last active UV/Image windows image is used.
		@warn: Deprecated, set bpy.data.images.active = image instead.
		@rtype: bool
		@return: True if the current image could be set, if no window was available, return False.
		"""
import id_generics
Image.__doc__ += id_generics.attributes