Difference between revisions of "ImageData"
Line 4: | Line 4: | ||
== Functions == | == Functions == | ||
{{#ask: [[Category:Functions]] [[parent::ImageData]] | {{#ask: [[Category:Functions]] [[parent::ImageData]] | ||
+ | | headers=hide | ||
+ | | ?Description | ||
+ | }} | ||
+ | {{#ask: [[Category:Functions]] [[parent::Data]] | ||
| headers=hide | | headers=hide | ||
| ?Description | | ?Description | ||
Line 33: | Line 37: | ||
</source> | </source> | ||
== Supertypes == | == Supertypes == | ||
+ | [[Data]] | ||
[[Object]] | [[Object]] | ||
== See Also == | == See Also == |
Revision as of 02:12, 13 February 2011
Raw (decoded) image data.
You can't draw ImageData directly to screen. See Image for that.
Contents
Functions
ImageData:encode | Encodes the ImageData to a file format and optionally writes it to the save directory. |
ImageData:getDimensions | Gets the width and height of the ImageData in pixels. |
ImageData:getFormat | Gets the pixel format of the ImageData. |
ImageData:getHeight | Gets the height of the ImageData in pixels. |
ImageData:getPixel | Gets the color of a pixel. |
ImageData:getString | Gets the full ImageData as a string. |
ImageData:getWidth | Gets the width of the ImageData in pixels. |
ImageData:mapPixel | Transform an image by applying a function to every pixel. |
ImageData:paste | Paste into ImageData from another source ImageData. |
ImageData:setPixel | Sets the color of a pixel. |
Data:clone | Creates a new copy of the Data object. |
Data:getFFIPointer | Gets an FFI pointer to the Data. |
Data:getPointer | Gets a pointer to the Data. |
Data:getSize | Gets the Data's size in bytes. |
Data:getString | Gets the full Data as a string. |
Object:release | Immediately destroys the object's Lua reference. |
Object:type | Gets the type of the object as a string. |
Object:typeOf | Checks whether an object is of a certain type. |
Examples
Images that have dimensions that are not a 2^n will display incorrectly as a white rectangle on some graphics chipsets. This function pads images so they will display correctly.
function newPaddedImage(filename)
local source = love.image.newImageData(filename)
local w, h = source:getWidth(), source:getHeight()
-- Find closest power-of-two.
local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
-- Only pad if needed:
if wp ~= w or hp ~= h then
local padded = love.image.newImageData(wp, hp)
padded:paste(source, 0, 0)
return love.graphics.newImage(padded)
end
return love.graphics.newImage(source)
end
Supertypes
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info