[Libav-user] Scaling via sws_scale() produces wrong colourvalues
Johannes Ebersold
johannes.ebersold at dfki.de
Tue Jun 28 17:53:54 CEST 2011
Hi,
I'm currently trying to scale a RGB picture using libswscale.
I tested my application by creating a complete white image, set every
byte to 255. But in the output after the scaling every pixel got the
value "254 251 251". I don't know what i got wrong and would be thankful
for any advice.
My Code is part of a larger project, i will just paste a snippet here...
So far i think, that i got something wrong initializing or using the
swscale.
m_convert_context = sws_getCachedContext(m_convert_context,
src_res.first, src_res.second, PIX_FMT_RGB24, m_dst_res.first,
m_dst_res.second, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
//src = Pointer to a packed RGB image with
unsigned char* src_data[3] = {src, NULL, NULL};
int src_stride[3] = {3*src_res.first, 0, 0}; //RGB stride is 3*width
/use offsets to set pointers, dst is just a pointer to some memory,
where the resulting image will be...
unsigned char* dst_data[3]= {dst, NULL, NULL};
int dst_stride[3] = {3*m_dst_res.first, 0, 0};
//convert
int ret = sws_scale(m_convert_context, src_data, src_stride, 0,
src_res.second, dst_data, dst_stride);
Thanks for any help!
Johannes
More information about the Libav-user
mailing list