wxWidget 에서 freeimage 사용해보신 분?

zelon의 이미지

간단히 이미지 파일을 읽어서 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 조합을 써보신 분 도움 부탁드립니다.

zelon의 이미지

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

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.