mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 10:05:39 +01:00
Add hooks to support outputing images whose pixels are not in block-stream order
This commit is contained in:
parent
a6e6138084
commit
9b7bb2cbc7
@ -56,6 +56,7 @@ class Image {
|
|||||||
public:
|
public:
|
||||||
Image(const CompressedImage &);
|
Image(const CompressedImage &);
|
||||||
Image(const ImageLoader &);
|
Image(const ImageLoader &);
|
||||||
|
Image(uint32 width, uint32 height, const uint32 *pixels);
|
||||||
~Image();
|
~Image();
|
||||||
|
|
||||||
Image(const Image &);
|
Image(const Image &);
|
||||||
@ -69,10 +70,15 @@ class Image {
|
|||||||
uint32 GetWidth() const { return m_Width; }
|
uint32 GetWidth() const { return m_Width; }
|
||||||
uint32 GetHeight() const { return m_Height; }
|
uint32 GetHeight() const { return m_Height; }
|
||||||
|
|
||||||
|
void SetBlockStreamOrder(bool flag) { m_bBlockStreamOrder = flag; }
|
||||||
|
bool GetBlockStreamOrder() const { return m_bBlockStreamOrder; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 m_Width;
|
uint32 m_Width;
|
||||||
uint32 m_Height;
|
uint32 m_Height;
|
||||||
|
|
||||||
|
bool m_bBlockStreamOrder;
|
||||||
|
|
||||||
uint8 *m_PixelData;
|
uint8 *m_PixelData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,9 +56,10 @@ static inline T sad( const T &a, const T &b ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Image::Image(const Image &other)
|
Image::Image(const Image &other)
|
||||||
: m_Width(other.m_Width)
|
: m_Width(other.m_Width)
|
||||||
, m_Height(other.m_Height)
|
, m_Height(other.m_Height)
|
||||||
, m_PixelData(new uint8[m_Width * m_Height * 4])
|
, m_PixelData(new uint8[m_Width * m_Height * 4])
|
||||||
|
, m_bBlockStreamOrder(other.GetBlockStreamOrder())
|
||||||
{
|
{
|
||||||
if(m_PixelData) {
|
if(m_PixelData) {
|
||||||
memcpy(m_PixelData, other.m_PixelData, m_Width * m_Height * 4);
|
memcpy(m_PixelData, other.m_PixelData, m_Width * m_Height * 4);
|
||||||
@ -68,10 +69,22 @@ Image::Image(const Image &other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image::Image(uint32 width, uint32 height, const uint32 *pixels)
|
||||||
|
: m_Width(width)
|
||||||
|
, m_Height(height)
|
||||||
|
, m_PixelData(new uint8[4 * m_Width * m_Height])
|
||||||
|
, m_bBlockStreamOrder(false)
|
||||||
|
{
|
||||||
|
if(m_PixelData && pixels)
|
||||||
|
memcpy(m_PixelData, pixels, m_Width * m_Height * sizeof(uint32));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Image &Image::operator=(const Image &other) {
|
Image &Image::operator=(const Image &other) {
|
||||||
|
|
||||||
m_Width = other.m_Width;
|
m_Width = other.m_Width;
|
||||||
m_Height = other.m_Height;
|
m_Height = other.m_Height;
|
||||||
|
m_bBlockStreamOrder = other.GetBlockStreamOrder();
|
||||||
|
|
||||||
if(m_PixelData) {
|
if(m_PixelData) {
|
||||||
delete [] m_PixelData;
|
delete [] m_PixelData;
|
||||||
@ -94,6 +107,7 @@ Image &Image::operator=(const Image &other) {
|
|||||||
Image::Image(const CompressedImage &ci)
|
Image::Image(const CompressedImage &ci)
|
||||||
: m_Width(ci.GetWidth())
|
: m_Width(ci.GetWidth())
|
||||||
, m_Height(ci.GetHeight())
|
, m_Height(ci.GetHeight())
|
||||||
|
, m_bBlockStreamOrder(true)
|
||||||
{
|
{
|
||||||
unsigned int bufSz = ci.GetWidth() * ci.GetHeight() * 4;
|
unsigned int bufSz = ci.GetWidth() * ci.GetHeight() * 4;
|
||||||
m_PixelData = new uint8[ bufSz ];
|
m_PixelData = new uint8[ bufSz ];
|
||||||
@ -109,6 +123,7 @@ Image::Image(const ImageLoader &loader)
|
|||||||
: m_Width(loader.GetWidth())
|
: m_Width(loader.GetWidth())
|
||||||
, m_Height(loader.GetHeight())
|
, m_Height(loader.GetHeight())
|
||||||
, m_PixelData(0)
|
, m_PixelData(0)
|
||||||
|
, m_bBlockStreamOrder(true)
|
||||||
{
|
{
|
||||||
if(loader.GetImageData()) {
|
if(loader.GetImageData()) {
|
||||||
m_PixelData = new uint8[ loader.GetImageDataSz() ];
|
m_PixelData = new uint8[ loader.GetImageDataSz() ];
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
|
|
||||||
ImageWriterPNG::ImageWriterPNG(const Image &im)
|
ImageWriterPNG::ImageWriterPNG(const Image &im)
|
||||||
: ImageWriter(im.GetWidth(), im.GetHeight(), im.RawData())
|
: ImageWriter(im.GetWidth(), im.GetHeight(), im.RawData())
|
||||||
|
, m_bBlockStreamOrder(im.GetBlockStreamOrder())
|
||||||
, m_StreamPosition(0)
|
, m_StreamPosition(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -130,8 +131,13 @@ bool ImageWriterPNG::WriteImage() {
|
|||||||
row_pointers[y] = row;
|
row_pointers[y] = row;
|
||||||
|
|
||||||
for (uint32 x = 0; x < m_Width; ++x) {
|
for (uint32 x = 0; x < m_Width; ++x) {
|
||||||
for(uint32 ch = 0; ch < 4; ch++) {
|
if(m_bBlockStreamOrder) {
|
||||||
*row++ = GetChannelForPixel(x, y, ch);
|
for(uint32 ch = 0; ch < 4; ch++) {
|
||||||
|
*row++ = GetChannelForPixel(x, y, ch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*(reinterpret_cast<uint32 *>(row) + x) =
|
||||||
|
(reinterpret_cast<const uint32 *>(m_PixelData))[y * m_Width + x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class ImageWriterPNG : public ImageWriter {
|
|||||||
|
|
||||||
virtual bool WriteImage();
|
virtual bool WriteImage();
|
||||||
private:
|
private:
|
||||||
|
bool m_bBlockStreamOrder;
|
||||||
uint32 m_StreamPosition;
|
uint32 m_StreamPosition;
|
||||||
friend class PNGStreamWriter;
|
friend class PNGStreamWriter;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user