Add support for embedded single channel previews, fixes #4419
This commit is contained in:
parent
b29029527d
commit
59ebf99f63
@ -78,7 +78,7 @@ void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
|||||||
* void Image16::setScanline (int row, unsigned char* buffer, int bps, int minValue[3], int maxValue[3]);
|
* void Image16::setScanline (int row, unsigned char* buffer, int bps, int minValue[3], int maxValue[3]);
|
||||||
* has not been implemented yet, because as of now, this method is called for IIOSF_FLOAT sample format only
|
* has not been implemented yet, because as of now, this method is called for IIOSF_FLOAT sample format only
|
||||||
*/
|
*/
|
||||||
void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
void Image16::setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue, float *maxValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
@ -92,12 +92,17 @@ void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minVa
|
|||||||
case (IIOSF_UNSIGNED_CHAR): {
|
case (IIOSF_UNSIGNED_CHAR): {
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
|
|
||||||
for (int i = 0; i < width; ++i) {
|
if(numSamples == 1) {
|
||||||
r(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
for (int i = 0; i < width; ++i) {
|
||||||
g(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
r(row, i) = g(row, i) = b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||||
b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < width; ++i) {
|
||||||
|
r(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||||
|
g(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||||
|
b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
return 8 * sizeof(unsigned short);
|
return 8 * sizeof(unsigned short);
|
||||||
}
|
}
|
||||||
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
||||||
virtual void setScanline (int row, unsigned char* buffer, int bps, float *minValue = nullptr, float *maxValue = nullptr);
|
virtual void setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue = nullptr, float *maxValue = nullptr);
|
||||||
|
|
||||||
// functions inherited from IImage16:
|
// functions inherited from IImage16:
|
||||||
virtual MyMutex& getMutex ()
|
virtual MyMutex& getMutex ()
|
||||||
|
@ -55,7 +55,7 @@ void Image8::getScanline (int row, unsigned char* buffer, int bps)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image8::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
void Image8::setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue, float *maxValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
@ -67,7 +67,13 @@ void Image8::setScanline (int row, unsigned char* buffer, int bps, float *minVal
|
|||||||
|
|
||||||
switch (sampleFormat) {
|
switch (sampleFormat) {
|
||||||
case (IIOSF_UNSIGNED_CHAR):
|
case (IIOSF_UNSIGNED_CHAR):
|
||||||
memcpy (data + row * width * 3u, buffer, width * 3);
|
if(numSamples == 1) {
|
||||||
|
for(size_t i = 0; i < static_cast<size_t>(width); ++i) {
|
||||||
|
data[row * width * 3 + 3 * i] = data[row * width * 3 + 3 * i + 1] = data[row * width * 3 + 3 * i + 2] = buffer[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
memcpy (data + row * width * 3u, buffer, width * 3);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (IIOSF_UNSIGNED_SHORT): {
|
case (IIOSF_UNSIGNED_SHORT): {
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
return 8 * sizeof(unsigned char);
|
return 8 * sizeof(unsigned char);
|
||||||
}
|
}
|
||||||
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
||||||
virtual void setScanline (int row, unsigned char* buffer, int bps, float *minValue = nullptr, float *maxValue = nullptr);
|
virtual void setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue = nullptr, float *maxValue = nullptr);
|
||||||
|
|
||||||
// functions inherited from IImage*:
|
// functions inherited from IImage*:
|
||||||
virtual MyMutex& getMutex ()
|
virtual MyMutex& getMutex ()
|
||||||
|
@ -44,7 +44,7 @@ Imagefloat::~Imagefloat ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call this method to handle floating points input values of different size
|
// Call this method to handle floating points input values of different size
|
||||||
void Imagefloat::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
void Imagefloat::setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue, float *maxValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
return 8 * sizeof(float);
|
return 8 * sizeof(float);
|
||||||
}
|
}
|
||||||
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
virtual void getScanline (int row, unsigned char* buffer, int bps);
|
||||||
virtual void setScanline (int row, unsigned char* buffer, int bps, float *minValue = nullptr, float *maxValue = nullptr);
|
virtual void setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples, float *minValue = nullptr, float *maxValue = nullptr);
|
||||||
|
|
||||||
// functions inherited from IImagefloat:
|
// functions inherited from IImagefloat:
|
||||||
virtual MyMutex& getMutex ()
|
virtual MyMutex& getMutex ()
|
||||||
|
@ -523,7 +523,7 @@ int ImageIO::loadJPEGFromMemory (const char* buffer, int bufsize)
|
|||||||
return IMIO_READERROR;
|
return IMIO_READERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
setScanline (cinfo.output_scanline - 1, row, 8);
|
setScanline (cinfo.output_scanline - 1, row, 8, cinfo.num_components);
|
||||||
|
|
||||||
if (pl && !(cinfo.output_scanline % 100)) {
|
if (pl && !(cinfo.output_scanline % 100)) {
|
||||||
pl->setProgress ((double)(cinfo.output_scanline) / cinfo.output_height);
|
pl->setProgress ((double)(cinfo.output_scanline) / cinfo.output_height);
|
||||||
@ -860,7 +860,7 @@ int ImageIO::loadTIFF (Glib::ustring fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setScanline (row, linebuffer, bitspersample, nullptr, nullptr);
|
setScanline (row, linebuffer, bitspersample);
|
||||||
|
|
||||||
if (pl && !(row % 100)) {
|
if (pl && !(row % 100)) {
|
||||||
pl->setProgress ((double)(row + 1) / height);
|
pl->setProgress ((double)(row + 1) / height);
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
|
|
||||||
virtual int getBPS () = 0;
|
virtual int getBPS () = 0;
|
||||||
virtual void getScanline (int row, unsigned char* buffer, int bps) {}
|
virtual void getScanline (int row, unsigned char* buffer, int bps) {}
|
||||||
virtual void setScanline (int row, unsigned char* buffer, int bps, float minValue[3] = nullptr, float maxValue[3] = nullptr) {}
|
virtual void setScanline (int row, unsigned char* buffer, int bps, unsigned int numSamples = 3, float minValue[3] = nullptr, float maxValue[3] = nullptr) {}
|
||||||
|
|
||||||
virtual bool readImage (Glib::ustring &fname, FILE *fh)
|
virtual bool readImage (Glib::ustring &fname, FILE *fh)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user