The same pixels in another format. Gray is made from colour with Rec. 709 luma, colour from gray by repeating it, alpha is added as 255 and dropped without compositing. Always a new image (a copy when the format already matches); an invalid image gives an empty one.
rgb := make_image(1, 1, .RGB8);
defer deinit(*rgb);
rgb.pixels[0], rgb.pixels[1], rgb.pixels[2] = 255, 255, 255;
gray := convert(rgb, .GRAY8);
defer deinit(*gray);
assert(gray.pixels[0] == 255);convert :: (image: Image, format: Pixel_Format) -> Image
Parameters
- image: Image
- format: Pixel_Format