Class for loading, manipulating and saving images.
// Load an image file from a file auto background = new Image(); if (!background.loadFromFile("background.jpg")) return -1; // Create a 20x20 image filled with black color auto image = new Image(); image.create(20, 20, Color.Black); // Copy image1 on image2 at position (10, 10) image.copy(background, 10, 10); // Make the top-left pixel transparent auto color = image.getPixel(0, 0); color.a = 0; image.setPixel(0, 0, color); // Save the image to a file if (!image.saveToFile("result.png")) return -1;
$(TEXTURE_LINK)
$(U Image) is an abstraction to manipulate images as bidimensional arrays of pixels. The class provides functions to load, read, write and save pixels, as well as many other useful functions.
$(U Image) can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a $(COLOR_LINK). All the functions that return an array of pixels follow this rule, and all parameters that you pass to $(U Image) functions (such as loadFromPixels) must use this representation as well.
An $(U Image) can be copied, but it is a heavy resource and if possible you should always use const references to pass or return them to avoid useless copies.