mirror of
https://github.com/ocornut/imgui.git
synced 2026-03-06 17:17:27 +00:00
Fonts: in ShowFontAtlas() preserve open-state for latest texture. Improve debug display.
This commit is contained in:
@@ -2420,7 +2420,7 @@ ImFontConfig::ImFontConfig()
|
||||
// - ImTextureData::DestroyPixels()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static int GetTextureFormatBytesPerPixel(ImTextureFormat format)
|
||||
int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
@@ -2431,13 +2431,24 @@ static int GetTextureFormatBytesPerPixel(ImTextureFormat format)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* ImTextureDataGetFormatName(ImTextureFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case ImTextureFormat_Alpha8: return "Alpha8";
|
||||
case ImTextureFormat_RGBA32: return "RGBA32";
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
void ImTextureData::Create(ImTextureFormat format, int w, int h)
|
||||
{
|
||||
DestroyPixels();
|
||||
Format = format;
|
||||
Width = w;
|
||||
Height = h;
|
||||
BytesPerPixel = GetTextureFormatBytesPerPixel(format);
|
||||
BytesPerPixel = ImTextureDataGetFormatBytesPerPixel(format);
|
||||
UseColors = false;
|
||||
Pixels = (unsigned char*)IM_ALLOC(Width * Height * BytesPerPixel);
|
||||
IM_ASSERT(Pixels != NULL);
|
||||
@@ -2798,7 +2809,7 @@ void ImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFo
|
||||
IM_ASSERT(src_pixels != NULL && dst_pixels != NULL);
|
||||
if (src_fmt == dst_fmt)
|
||||
{
|
||||
int line_sz = w * GetTextureFormatBytesPerPixel(src_fmt);
|
||||
int line_sz = w * ImTextureDataGetFormatBytesPerPixel(src_fmt);
|
||||
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
|
||||
memcpy(dst_pixels, src_pixels, line_sz);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user