用bmp的原始數據怎麼構造一個wximage Topic is solved

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
nalisaki
Earned a small fee
Earned a small fee
Posts: 17
Joined: Wed Mar 21, 2012 1:36 pm

用bmp的原始數據怎麼構造一個wximage

Post by nalisaki » Mon Mar 26, 2012 12:07 pm

bmp的原始數據是指一幅.bmp圖像在內存中的映像。用 wxImage (int width, int height, unsigned char *data, bool static_data=false)這個構造不成功啊,這個構造函數的參考資料(官方網站上的)對unsigned char* data這個參數的解釋並不是很清楚,它的格式應該是怎樣的呢?還有其他方法嗎?多謝!

Utensil
Moderator
Moderator
Posts: 423
Joined: Sun Feb 03, 2008 11:38 am
Location: China

Re: 用bmp的原始數據怎麼構造一個wximage

Post by Utensil » Tue Mar 27, 2012 5:00 am

可参考 http://forums.wxwidgets.org/viewtopic.php?p=86267#86267 ,这里面有解释也有示例代码。
In fascination of creating worlds by words, and in pursuit of words behind the world.

On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/

nalisaki
Earned a small fee
Earned a small fee
Posts: 17
Joined: Wed Mar 21, 2012 1:36 pm

Re: 用bmp的原始數據怎麼構造一個wximage

Post by nalisaki » Wed Mar 28, 2012 5:11 am

我用wximage的Create函數解決了。
具體代碼是:

Code: Select all

    wxMutexGuiEnter();
    wxImage imgTmp;
    imgTmp.Create(width,height,Buffer, true);
    wxBitmap bmpTmp(imgTmp);
    wxMemoryDC memDC;
    memDC.SelectObject(bmpTmp);
    wxClientDC destDC(Panel2);
    //wxPaintDC destDC(Panel2);
    destDC.Blit(4, 4, // Draw at (100, 100)
                bmpTmp.GetWidth(),
                bmpTmp.GetHeight(), // Drawfullbitmap
                &memDC, // Draw from memDC
                0, 0,   // Draw from bitmap origin
                wxCOPY, // Logical operation
                false) ; // Take mask into account no
    memDC.SelectObject(wxNullBitmap);
    wxMutexGuiLeave();

Post Reply