FreeImage with wxWidgets
2010-07-18
wxWidgets과 FreeImage의 조합이 필요하다면 아래의 소스를 분석해본다.
http://sourceforge.net/projects/comical/
http://sourceforge.net/projects/kujawiak/files/
아래의 코드도 보고.
출처: http://kldp.org/node/88572
void MyFrame::Test(wxCommandEvent& event) { if ( false == m_image.load("a.jpg") ) { wxMessageBox(_T("can not load"), _T("warning"), wxOK, this); return; } m_image.convertTo32Bits(); { int width = m_image.getWidth(); int height = m_image.getHeight(); int scanWidth = m_image.getScanWidth(); // Create the wxBitmap object m_pBitmap = new wxBitmap(width, height, 32); typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> PixelData; wxAlphaPixelData data(*m_pBitmap); data.UseAlpha(); PixelData::Iterator p(data); // Iterate the image lines: for(int y = height-1; y >= 0; --y) { PixelData::Iterator rowStart = p; // Iterate the current line pixels: BYTE* pLineData = m_image.getScanLine(y); for(int x = 0; x < width; ++x, ++p, pLineData += 4) { p.Red() = pLineData[2]; p.Green() = pLineData[1]; p.Blue() = pLineData[0]; p.Alpha() = pLineData[3]; } p = rowStart; p.OffsetY(data, 1); } } wxClientDC dc(this); dc.DrawBitmap(*m_pBitmap, wxPoint(0,0)); }
아래는 FreeImage를 이용하여 이미지를 보여주는 예제이다.
http://www.codeproject.com/KB/graphics/freeimage_display_demo.aspx
Categorized as: Programming
답글 남기기