mirror of
https://github.com/opencv/opencv.git
synced 2026-09-11 04:43:22 -05:00
SunRasterDecoder::readData() only called CvtPaletteToGray() when the file contained a color palette (m_maptype == RMT_EQUAL_RGB). But SunRasterEncoder always writes RMT_NONE (no palette), so gray_palette[] stayed zero-initialized and FillGrayRow8() mapped every pixel to 0. Fix: call CvtPaletteToGray() whenever reading as grayscale, regardless of palette type. readHeader() already fills m_palette correctly via FillGrayPalette() for the RMT_NONE case. Add regression test Imgcodecs_SunRaster.imread_grayscale_roundtrip that writes a full 0-255 ramp, reads it back with IMREAD_GRAYSCALE, and checks NORM_INF == 0. Without the fix, NORM_INF == 255 (all black). Remove the "broken (black result)" skip for ras in read_write_GRAYSCALE.