wxWidget 에서 freeimage 사용해보신 분?
글쓴이: zelon / 작성시간: 금, 2007/11/23 - 6:40오전
간단히 이미지 파일을 읽어서 wxWidget 의 창에 보여주는 프로그램을 만들고 있습니다.
FreeImagePlus.h 를 이용하고, wxClientDC 를 통해 보여주려고 하는데,
wxImage, wxBitmap 등등을 이용해도 이상하게 검은 화면만 보이고 -_-; 삽질 중입니다. 구글링해도 이런 조합으로는 잘 안쓰는지 찾기가 힘드네요.
관련 소스는,
void MyFrame::Test(wxCommandEvent& event)
{
/*
wxMessageBox(_T("This is a wxWindows Hello world sample"),
_T("About Hello World"), wxOK | wxICON_INFORMATION, this);
*/
fipImage m_image;
if ( false == m_image.load("a.jpg") )
{
wxMessageBox(_T("can not load"), _T("warning"), wxOK, this);
return;
}
wxImage image(m_image.getWidth(), m_image.getHeight(), m_image);
wxBitmap bit(image);
wxClientDC dc(this);
dc.DrawBitmap(bit, wxPoint(50,50));
} 이런식입니다만, 잘 안되네요. 혹시 freeimage + wxWidget 조합을 써보신 분 도움 부탁드립니다.
Forums:


freeimage 의 포럼에는
freeimage 의 포럼에는 wxWidget 관련 글이 없던데, wxWidget 포럼에는 freeimage 관련 글이 2개나 있더군요. 그래서 일단 다음과 같은 결과를 얻었습니다.
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)); }근데 아무래도 위의 코드는 loop 를 돌아서 성능이 좀 떨어질 것 같은데, 더 좋은 방법은 없을까요?
-----------------------------------------------------------------------
GPL 오픈소스 윈도우용 이미지 뷰어 ZViewer - http://kldp.net/projects/zviewer/
http://www.wimy.com
-----------------------------------------------------------------------
GPL 오픈소스 윈도우용 이미지 뷰어 ZViewer - http://zviewer.wimy.com
블로그 : http://blog.wimy.com
댓글 달기