我有从我的手机捕获的图像的原始数据,它的分辨率是 480*800,格式是 RGBA。然后我想用 wxImage 函数将它保存到一个 jpeg 图像中。鳕鱼如下:
wxFile m_bufferfile = wxFile(wxT("out.raw"));
if(!m_bufferfile->IsOpened())
{
wxLogMessage( _T("Fail to open the config file.") );
}
m_count = m_bufferfile->Length();
unsigned char* rawdata = new unsigned char[m_count];
for(unsigned int i = 0; i < m_count; i=i+4)
{
m_bufferfile->Seek(1,wxFromCurrent);
m_bufferfile->Read(rawdata, 3);
}
wxImage *image = new wxImage(480, 800, rawdata, false);
image->SaveFile(wxT("raw.jpg"),wxBITMAP_TYPE_JPEG);
当我打开 raw.jpg 时,它变成了黑色。有错吗?