Skip to content

Commit

Permalink
Details panel now shows both alpha-mode and channel-type -- if the cu…
Browse files Browse the repository at this point in the history
…rrent image supplies this information (not all images do). Added tooltip text for both new fields. Moved tooltip for colour-profile to the Colour Profile field instead of the title field.
  • Loading branch information
bluescan committed Dec 26, 2023
1 parent 5d1975a commit 4ba7fac
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 25 deletions.
58 changes: 49 additions & 9 deletions Src/Details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ void Viewer::ShowImageDetailsOverlay(bool* popen, float x, float y, float w, flo

ShowToolTip
(
"Right-Click to Change Anchor\n"
"\n"
"The Colour Profile is a best guess at the type of pixel data present.\n"
"LDR means low dynamic range (0.0 to 1.0). HDR means values above 1.0\n\n"
"sRGB : LDR RGB in the sRGB colour space. LDR alpha in linear space.\n"
"gRGB : LDR RGB in gamma colour space. LDR alpha in linear space.\n"
"lRGB : LDR RGBA all in linear space.\n"
"HDRa : HDR RGB in linear space. LDR alpha in linear space.\n"
"HDRA : HDR RGBA all in linear space.\n"
"Right-Click to Change Anchor"
);
ImGui::Separator();

Expand Down Expand Up @@ -107,6 +99,54 @@ void Viewer::ShowImageDetailsOverlay(bool* popen, float x, float y, float w, flo
const char* colourProfileName = tGetColourProfileShortName(info.SrcColourProfile);
tAssert(colourProfileName);
ImGui::Text("Colour Profile: %s", colourProfileName);
ShowToolTip
(
"The Colour Profile is a best guess at the type of pixel data present.\n"
"LDR means low dynamic range (0.0 to 1.0). HDR means values above 1.0\n\n"
"sRGB : LDR RGB in the sRGB colour space. LDR alpha in linear space.\n"
"gRGB : LDR RGB in gamma colour space. LDR alpha in linear space.\n"
"lRGB : LDR RGBA all in linear space.\n"
"HDRa : HDR RGB in linear space. LDR alpha in linear space.\n"
"HDRA : HDR RGBA all in linear space."
);

// Only display AlphaMode and ChannelType if they are specified. Most image formats will not
// be able to provide these values so we don't want to waste screen real-estate.
if (info.AlphaMode != tAlphaMode::Unspecified)
{
const char* alphaModeName = tGetAlphaModeShortName(info.AlphaMode);
tAssert(alphaModeName);
ImGui::Text("Alpha Mode: %s", alphaModeName);
ShowToolTip
(
"The Alpha Mode specifies whether the alpha has been premultiplied into\n"
"the colour channels. Mult means is has. Norm means is hasn't.\n"
"\n"
"Not all images supply this information, so it may not be displayed."
);
}

if (info.ChannelType != tChannelType::Unspecified)
{
const char* channelTypeName = tGetChannelTypeShortName(info.ChannelType);
tAssert(channelTypeName);
ImGui::Text("Channel Type: %s", channelTypeName);
ShowToolTip
(
"The Channel Type specifies how the data was intended to be interpreted\n"
"by a graphics API. UINT8N means unsigned 8-bit integer data should be\n"
"sampled as normalized data in the 0.0 to 1.0 range. UINT8N, UINT16N,\n"
"and UINT32N all correspond to the Vulkan and DirectX UNORM specifier.\n"
"\n"
"If there is no N, like SINT8, it should be interpreted as an integer. In this\n"
"case a signed integer in the range [-128, 127]. Channel types also include\n"
"UFLOAT, SFLOAT, UHALF, SHALF. Half-precision floats are supported\n"
"natively in some variants of HLSL and GLSL while other variants use full-\n"
"precision under the hood.\n"
"\n"
"Not all images supply this information, so it may not be displayed."
);
}

ImGui::Text("Bits Per Pixel: %s", bppStr.Chr());
switch (info.Opacity)
Expand Down
40 changes: 24 additions & 16 deletions Src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ bool Image::Load(bool loadParamsFromConfig)
if ((Filetype == tSystem::tFileType::PNG) && detectAPNGInsidePNG && tImageAPNG::IsAnimatedPNG(Filename))
loadingFiletype = tSystem::tFileType::APNG;

Info.SrcPixelFormat = tPixelFormat::Invalid;
Info.SrcColourProfile = tColourProfile::Unspecified;
Info.SrcPixelFormat = tPixelFormat::Invalid;
Info.SrcColourProfile = tColourProfile::Unspecified;
Info.AlphaMode = tAlphaMode::Unspecified;
Info.ChannelType = tChannelType::Unspecified;
bool success = false;

switch (loadingFiletype)
Expand Down Expand Up @@ -276,8 +278,8 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok)
break;

Info.SrcPixelFormat = hdr.GetPixelFormatSrc();
Info.SrcColourProfile = tColourProfile::lRGB;
Info.SrcPixelFormat = hdr.GetPixelFormatSrc();
Info.SrcColourProfile = hdr.GetColourProfileSrc();
int width = hdr.GetWidth();
int height = hdr.GetHeight();
tPixel* pixels = hdr.StealPixels();
Expand All @@ -295,8 +297,8 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok)
break;

Info.SrcPixelFormat = ico.GetPixelFormatSrc();
Info.SrcColourProfile = tColourProfile::sRGB;
Info.SrcPixelFormat = ico.GetPixelFormatSrc();
Info.SrcColourProfile = ico.GetColourProfileSrc();
int numFrames = ico.GetNumFrames();
for (int p = 0; p < numFrames; p++)
{
Expand Down Expand Up @@ -327,8 +329,8 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok)
break;

Info.SrcPixelFormat = jpg.GetPixelFormatSrc();
Info.SrcColourProfile = tColourProfile::sRGB;
Info.SrcPixelFormat = jpg.GetPixelFormatSrc();
Info.SrcColourProfile = jpg.GetColourProfileSrc();
int width = jpg.GetWidth();
int height = jpg.GetHeight();
tPixel* pixels = jpg.StealPixels();
Expand Down Expand Up @@ -463,8 +465,10 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok || !dds.IsValid())
break;

Info.SrcPixelFormat = dds.GetPixelFormatSrc();
Info.SrcColourProfile = dds.GetColourProfileSrc();
Info.SrcPixelFormat = dds.GetPixelFormatSrc();
Info.SrcColourProfile = dds.GetColourProfileSrc();
Info.AlphaMode = dds.GetAlphaMode();
Info.ChannelType = dds.GetChannelType();

// Appends to the Pictures list.
PopulatePicturesDDS(dds);
Expand Down Expand Up @@ -492,8 +496,10 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok || !pvr.IsValid())
break;

Info.SrcPixelFormat = pvr.GetPixelFormatSrc();
Info.SrcColourProfile = pvr.GetColourProfileSrc();
Info.SrcPixelFormat = pvr.GetPixelFormatSrc();
Info.SrcColourProfile = pvr.GetColourProfileSrc();
Info.AlphaMode = pvr.GetAlphaMode();
Info.ChannelType = pvr.GetChannelType();

// Appends to the Pictures list.
PopulatePicturesPVR(pvr);
Expand All @@ -513,8 +519,10 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok || !ktx.IsValid())
break;

Info.SrcPixelFormat = ktx.GetPixelFormatSrc();
Info.SrcColourProfile = ktx.GetColourProfileSrc();
Info.SrcPixelFormat = ktx.GetPixelFormatSrc();
Info.SrcColourProfile = ktx.GetColourProfileSrc();
Info.AlphaMode = ktx.GetAlphaMode();
Info.ChannelType = ktx.GetChannelType();

// Appends to the Pictures list.
PopulatePicturesKTX(ktx);
Expand Down Expand Up @@ -558,8 +566,8 @@ bool Image::Load(bool loadParamsFromConfig)
if (!ok)
break;

Info.SrcPixelFormat = pkm.GetPixelFormatSrc();
Info.SrcColourProfile = pkm.GetColourProfileSrc();
Info.SrcPixelFormat = pkm.GetPixelFormatSrc();
Info.SrcColourProfile = pkm.GetColourProfileSrc();
int width = pkm.GetWidth();
int height = pkm.GetHeight();

Expand Down
2 changes: 2 additions & 0 deletions Src/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class Image : public tLink<Image>
bool IsValid() const { return (SrcPixelFormat != tImage::tPixelFormat::Invalid); }
tImage::tPixelFormat SrcPixelFormat = tImage::tPixelFormat::Invalid;
tColourProfile SrcColourProfile = tColourProfile::Unspecified;
tAlphaMode AlphaMode = tAlphaMode::Unspecified;
tChannelType ChannelType = tChannelType::Unspecified;

enum class OpacityType { False, True, Varies }; // Varies is for when there is more than one picture in the image (animated, mipmaps, etc) and they are not set all the same.
OpacityType Opacity = OpacityType::False;
Expand Down

0 comments on commit 4ba7fac

Please sign in to comment.