Merge pull request #4454 from Beep6581/monochrome-thumb
Fix wrong monochrome thumbnails
This commit is contained in:
commit
b0092a2436
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -332,10 +332,16 @@ skip_block:
|
|||||||
pre_mul_[3] = pre_mul_[1] = (pre_mul_[3] + pre_mul_[1]) / 2;
|
pre_mul_[3] = pre_mul_[1] = (pre_mul_[3] + pre_mul_[1]) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colors == 1)
|
if (colors == 1) {
|
||||||
|
// there are monochrome cameras with wrong matrix. We just replace with this one.
|
||||||
|
rgb_cam[0][0] = 1; rgb_cam[1][0] = 0; rgb_cam[2][0] = 0;
|
||||||
|
rgb_cam[0][1] = 0; rgb_cam[1][1] = 1; rgb_cam[2][1] = 0;
|
||||||
|
rgb_cam[0][2] = 0; rgb_cam[1][2] = 0; rgb_cam[2][2] = 1;
|
||||||
|
|
||||||
for (c = 1; c < 4; c++) {
|
for (c = 1; c < 4; c++) {
|
||||||
cblack_[c] = cblack_[0];
|
cblack_[c] = cblack_[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool multiple_whites = false;
|
bool multiple_whites = false;
|
||||||
int largest_white = this->get_white(0);
|
int largest_white = this->get_white(0);
|
||||||
|
@ -1593,7 +1593,7 @@ int RawImageSource::load (const Glib::ustring &fname)
|
|||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
imatrices.rgb_cam[i][j] = ri->get_rgb_cam(i, j);
|
imatrices.rgb_cam[i][j] = ri->get_colors() == 1 ? (i == j) : ri->get_rgb_cam(i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute inverse of the color transformation matrix
|
// compute inverse of the color transformation matrix
|
||||||
|
Loading…
x
Reference in New Issue
Block a user