mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
ImageData can track whether they're meant to be loaded into a Texture with a non-sRGB format when gamma correct rendering is enabled.
Fixes #1556. * Add ImageData/CompressedImageData:setLinear and ImageData/CompressedImageData:isLinear. The flag is used as a hint when loading a texture from the data to determine if the format should not be treated as sRGB-encoded. The 'linear' flag in newImage overrides this. * love.graphics.readbackTexture automatically sets the linear flag on ImageData it returns when the texture's format is linear. This allows an ImageData generated via readback to be fed back into a new Texture and the format will match the original Canvas. * Also clean up some image decoding code.
This commit is contained in:
@@ -475,7 +475,7 @@ bool PVRHandler::canParseCompressed(Data *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
StrongRef<ByteData> PVRHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
|
||||
StrongRef<ByteData> PVRHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format)
|
||||
{
|
||||
if (!canParseCompressed(filedata))
|
||||
throw love::Exception("Could not decode compressed data (not a PVR file?)");
|
||||
@@ -510,6 +510,9 @@ StrongRef<ByteData> PVRHandler::parseCompressed(Data *filedata, std::vector<Stro
|
||||
|
||||
PixelFormat cformat = convertFormat(pixelformat, channeltype);
|
||||
|
||||
if (header3.colorSpace == 1)
|
||||
cformat == getSRGBPixelFormat(cformat);
|
||||
|
||||
if (cformat == PIXELFORMAT_UNKNOWN)
|
||||
throw love::Exception("Could not parse PVR file: unsupported image format.");
|
||||
|
||||
@@ -551,8 +554,6 @@ StrongRef<ByteData> PVRHandler::parseCompressed(Data *filedata, std::vector<Stro
|
||||
}
|
||||
|
||||
format = cformat;
|
||||
sRGB = (header3.colorSpace == 1);
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user