Skip to content

Commit

Permalink
Updated viewer to compile with latest tPixel naming in tacent.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescan committed Jan 13, 2024
1 parent da96fdb commit 7564537
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
50 changes: 25 additions & 25 deletions Src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcPixelFormat = bmp.GetPixelFormatSrc();
int width = bmp.GetWidth();
int height = bmp.GetHeight();
tPixel4* pixels = bmp.StealPixels();
tPixel4b* pixels = bmp.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand Down Expand Up @@ -282,7 +282,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcColourProfile = hdr.GetColourProfileSrc();
int width = hdr.GetWidth();
int height = hdr.GetHeight();
tPixel4* pixels = hdr.StealPixels();
tPixel4b* pixels = hdr.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand Down Expand Up @@ -338,7 +338,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcColourProfile = jpg.GetColourProfileSrc();
int width = jpg.GetWidth();
int height = jpg.GetHeight();
tPixel4* pixels = jpg.StealPixels();
tPixel4b* pixels = jpg.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand Down Expand Up @@ -367,7 +367,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcPixelFormat = png.GetPixelFormatSrc();
int width = png.GetWidth();
int height = png.GetHeight();
tPixel4* pixels = png.StealPixels();
tPixel4b* pixels = png.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand All @@ -385,7 +385,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcPixelFormat = tga.GetPixelFormatSrc();
int width = tga.GetWidth();
int height = tga.GetHeight();
tPixel4* pixels = tga.StealPixels();
tPixel4b* pixels = tga.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand All @@ -403,7 +403,7 @@ bool Image::Load(bool loadParamsFromConfig)
Info.SrcPixelFormat = qoi.GetPixelFormatSrc();
int width = qoi.GetWidth();
int height = qoi.GetHeight();
tPixel4* pixels = qoi.StealPixels();
tPixel4b* pixels = qoi.StealPixels();

tPicture* picture = new tPicture(width, height, pixels, false);
Pictures.Append(picture);
Expand Down Expand Up @@ -557,7 +557,7 @@ bool Image::Load(bool loadParamsFromConfig)

tLayer* layer = astc.StealLayer();
tAssert(layer && (layer->PixelFormat == tPixelFormat::R8G8B8A8));
tPixel4* pixels = (tPixel4*)layer->StealData();
tPixel4b* pixels = (tPixel4b*)layer->StealData();

// Give the pixels to the tPicture.
tPicture* picture = new tPicture(width, height, pixels, false);
Expand All @@ -583,7 +583,7 @@ bool Image::Load(bool loadParamsFromConfig)

tLayer* layer = pkm.StealLayer();
tAssert(layer && (layer->PixelFormat == tPixelFormat::R8G8B8A8));
tPixel4* pixels = (tPixel4*)layer->StealData();
tPixel4b* pixels = (tPixel4b*)layer->StealData();

// Give the pixels to the tPicture.
tPicture* picture = new tPicture(width, height, pixels, false);
Expand Down Expand Up @@ -940,9 +940,9 @@ int Image::GetMemSizeBytes() const
{
int numBytes = 0;
for (tPicture* pic = Pictures.First(); pic; pic = pic->Next())
numBytes += pic->GetNumPixels() * sizeof(tPixel4);
numBytes += pic->GetNumPixels() * sizeof(tPixel4b);

numBytes += AltPicture.IsValid() ? AltPicture.GetNumPixels()*sizeof(tPixel4) : 0;
numBytes += AltPicture.IsValid() ? AltPicture.GetNumPixels()*sizeof(tPixel4b) : 0;
return numBytes;
}

Expand Down Expand Up @@ -974,7 +974,7 @@ void Image::PopulatePicturesDDS(const tImageDDS& dds)

tLayer* topMip = layers[face].First();
tAssert(topMip->PixelFormat == tPixelFormat::R8G8B8A8);
Pictures.Append(new tPicture(w, h, (tPixel4*)topMip->Data, true));
Pictures.Append(new tPicture(w, h, (tPixel4b*)topMip->Data, true));

// Lets reset the list so it doesn't do anything bad when destructed.
layers[face].Reset();
Expand All @@ -990,7 +990,7 @@ void Image::PopulatePicturesDDS(const tImageDDS& dds)

int numMipmaps = layers.GetNumItems();
for (tLayer* layer = layers.First(); layer; layer = layer->Next())
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4*)layer->Data, true));
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4b*)layer->Data, true));

layers.Reset();
}
Expand All @@ -1004,7 +1004,7 @@ void Image::CreateAltPicturesDDS(const tImageDDS& dds)
int width = Pictures.First()->GetWidth();
int height = Pictures.First()->GetHeight();

AltPicture.Set(width*4, height*3, tPixel4::transparent);
AltPicture.Set(width*4, height*3, tPixel4b::transparent);
int originX, originY;

// PosZ
Expand Down Expand Up @@ -1058,7 +1058,7 @@ void Image::CreateAltPicturesDDS(const tImageDDS& dds)
width += layer->GetWidth();
int height = GetHeight();

AltPicture.Set(width, height, tPixel4::transparent);
AltPicture.Set(width, height, tPixel4b::transparent);
int originY = 0;
int originX = 0;
for (tPicture* layer = Pictures.First(); layer; layer = layer->Next())
Expand All @@ -1067,7 +1067,7 @@ void Image::CreateAltPicturesDDS(const tImageDDS& dds)
{
for (int x = 0; x < layer->GetWidth(); x++)
{
tPixel4 pixel = layer->GetPixel(x, y);
tPixel4b pixel = layer->GetPixel(x, y);
AltPicture.SetPixel(originX + x, y, pixel);
}
}
Expand Down Expand Up @@ -1105,7 +1105,7 @@ void Image::PopulatePicturesPVR(const tImagePVR& pvr)

tLayer* topMip = layers[face].First();
tAssert(topMip->PixelFormat == tPixelFormat::R8G8B8A8);
Pictures.Append(new tPicture(w, h, (tPixel4*)topMip->Data, true));
Pictures.Append(new tPicture(w, h, (tPixel4b*)topMip->Data, true));

// Lets reset the list so it doesn't do anything bad when destructed.
layers[face].Reset();
Expand All @@ -1121,7 +1121,7 @@ void Image::PopulatePicturesPVR(const tImagePVR& pvr)

int numMipmaps = layers.GetNumItems();
for (tLayer* layer = layers.First(); layer; layer = layer->Next())
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4*)layer->Data, true));
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4b*)layer->Data, true));

layers.Reset();
}
Expand All @@ -1135,7 +1135,7 @@ void Image::CreateAltPicturesPVR(const tImagePVR& pvr)
int width = Pictures.First()->GetWidth();
int height = Pictures.First()->GetHeight();

AltPicture.Set(width*4, height*3, tPixel4::transparent);
AltPicture.Set(width*4, height*3, tPixel4b::transparent);
int originX, originY;

// PosZ
Expand Down Expand Up @@ -1189,7 +1189,7 @@ void Image::CreateAltPicturesPVR(const tImagePVR& pvr)
width += layer->GetWidth();
int height = GetHeight();

AltPicture.Set(width, height, tPixel4::transparent);
AltPicture.Set(width, height, tPixel4b::transparent);
int originY = 0;
int originX = 0;
for (tPicture* layer = Pictures.First(); layer; layer = layer->Next())
Expand All @@ -1198,7 +1198,7 @@ void Image::CreateAltPicturesPVR(const tImagePVR& pvr)
{
for (int x = 0; x < layer->GetWidth(); x++)
{
tPixel4 pixel = layer->GetPixel(x, y);
tPixel4b pixel = layer->GetPixel(x, y);
AltPicture.SetPixel(originX + x, y, pixel);
}
}
Expand Down Expand Up @@ -1236,7 +1236,7 @@ void Image::PopulatePicturesKTX(const tImageKTX& ktx)

tLayer* topMip = layers[face].First();
tAssert(topMip->PixelFormat == tPixelFormat::R8G8B8A8);
Pictures.Append(new tPicture(w, h, (tPixel4*)topMip->Data, true));
Pictures.Append(new tPicture(w, h, (tPixel4b*)topMip->Data, true));

// Lets reset the list so it doesn't do anything bad when destructed.
layers[face].Reset();
Expand All @@ -1252,7 +1252,7 @@ void Image::PopulatePicturesKTX(const tImageKTX& ktx)

int numMipmaps = layers.GetNumItems();
for (tLayer* layer = layers.First(); layer; layer = layer->Next())
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4*)layer->Data, true));
Pictures.Append(new tPicture(layer->Width, layer->Height, (tPixel4b*)layer->Data, true));

layers.Reset();
}
Expand All @@ -1266,7 +1266,7 @@ void Image::CreateAltPicturesKTX(const tImageKTX& ktx)
int width = Pictures.First()->GetWidth();
int height = Pictures.First()->GetHeight();

AltPicture.Set(width*4, height*3, tPixel4::transparent);
AltPicture.Set(width*4, height*3, tPixel4b::transparent);
int originX, originY;

// PosZ
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void Image::CreateAltPicturesKTX(const tImageKTX& ktx)
width += layer->GetWidth();
int height = GetHeight();

AltPicture.Set(width, height, tPixel4::transparent);
AltPicture.Set(width, height, tPixel4b::transparent);
int originY = 0;
int originX = 0;
for (tPicture* layer = Pictures.First(); layer; layer = layer->Next())
Expand All @@ -1329,7 +1329,7 @@ void Image::CreateAltPicturesKTX(const tImageKTX& ktx)
{
for (int x = 0; x < layer->GetWidth(); x++)
{
tPixel4 pixel = layer->GetPixel(x, y);
tPixel4b pixel = layer->GetPixel(x, y);
AltPicture.SetPixel(originX + x, y, pixel);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Src/TacentView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,9 @@ bool Viewer::OnPasteImageFromClipboard()
int width = spec.width;
int height = spec.height;
uint32* srcData = (uint32*)img.data();
tPixel4* dstData = new tPixel4[width*height];
tPixel4b* dstData = new tPixel4b[width*height];

int bytesPerRow = width*sizeof(tPixel4);
int bytesPerRow = width*sizeof(tPixel4b);
for (int y = height-1; y >= 0; y--)
tStd::tMemcpy((uint8*)dstData + ((height-1)-y)*bytesPerRow, (uint8*)srcData + y*bytesPerRow, bytesPerRow);

Expand Down

0 comments on commit 7564537

Please sign in to comment.