ImageData (Русский)
Декодированные данные изображения.
Вы не можете использовать ImageData для рисования на экране. Смотрите Image для этого.
Функции
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. |
Пример
Изображения с разрешением не равным 2^n будут отображаться как белые прямоугольники на некоторых графических чипах. Эта функция подгоняет изображение, так что они будут отображаться корректно.
function newPaddedImage(filename) local source = love.image.newImageData(filename) local w, h = source:getWidth(), source:getHeight() -- Нахождение нужной степени для двойки. 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))) -- Если подгонка нужна: 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
Смотрите также
Другие языки
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