mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 18:13:13 +08:00
imgcodecs: fix webp IMREAD_GRAYSCALE loading
This commit is contained in:
parent
636ab095b0
commit
cbda9b332b
@ -162,6 +162,8 @@ bool WebPDecoder::readData(Mat &img)
|
|||||||
{
|
{
|
||||||
if( m_width > 0 && m_height > 0 )
|
if( m_width > 0 && m_height > 0 )
|
||||||
{
|
{
|
||||||
|
bool convert_grayscale = (img.type() == CV_8UC1); // IMREAD_GRAYSCALE requested
|
||||||
|
|
||||||
if (img.cols != m_width || img.rows != m_height || img.type() != m_type)
|
if (img.cols != m_width || img.rows != m_height || img.type() != m_type)
|
||||||
{
|
{
|
||||||
img.create(m_height, m_width, m_type);
|
img.create(m_height, m_width, m_type);
|
||||||
@ -184,6 +186,10 @@ bool WebPDecoder::readData(Mat &img)
|
|||||||
|
|
||||||
if(res_ptr == out_data)
|
if(res_ptr == out_data)
|
||||||
{
|
{
|
||||||
|
if (convert_grayscale)
|
||||||
|
{
|
||||||
|
cvtColor(img, img, COLOR_BGR2GRAY);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user