我有从手机拍摄的图像的原始数据,其分辨率为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时,它变成了黑色。 有错吗?
答案 0 :(得分:1)
你有一个错误:
m_bufferfile->Read(rawdata, 3);
您只读过rawdata
缓冲区的开头。