Difference between revisions of "(Image):replacePixels"
(Created page with "{{newin|0.11.0|110|type=function|text=This function replaces (Image):refresh}} Replace the contents of an Image. == Function == === Synopsis === <source lang="lua">...") |
(No difference)
|
Revision as of 14:44, 7 January 2018
Available since LÖVE 0.11.0 |
This function replaces (Image):refresh. |
Replace the contents of an Image.
Function
Synopsis
Image:replacePixels( data, slice, mipmap )
Arguments
ImageData data
- The new ImageData to replace the contents with.
number slice
- Which slice to replace, if applicable.
number mipmap (0)
- The mimap level of the new ImageData. If 0 Image:replacePixels will generate new mimaps.
Returns
Nothing.
Examples
function love.load()
imagedata = love.image.newImageData("pig.png")
image = love.graphics.newImage(imagedata)
end
function love.draw()
love.graphics.draw(image)
end
function love.keypressed(key)
if key == "e" then
-- Modify the original ImageData and apply the changes to the Image.
imagedata:mapPixel(function(x, y, r, g, b, a) return r/2, g/2, b/2, a/2 end)
image:replacePixels(imagedata)
end
end
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