如何显示以矩阵格式存储的图片? Topic is solved

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
samggyy
Experienced Solver
Experienced Solver
Posts: 95
Joined: Wed Aug 15, 2007 7:34 am
Location: London, UK/ China
Contact:

如何显示以矩阵格式存储的图片?

Post by samggyy » Thu Dec 11, 2008 1:25 pm

我用一下代码新建一个矩阵:

Code: Select all

double **testImage= CreateMatrix<double>(64, 64);
然后赋值到矩阵中,赋值后的矩阵如附件。然后我想将此矩阵显示为一一幅图片(此图片为二维灰度图),在wxWidgets的GUI中显示。请问怎么做?

如下代码可以编译,但是显示的是一幅全黑的图片,没有灰度。

Code: Select all

wxImage * imageOPT = new wxImage(64, 64, testImage); 
wxBitmap bitmapOPT(*imageOPT );
wxBackgroundBitmap * pNotebookBackground = new wxBackgroundBitmap(bitmapOPT); 
pPanelOriginal->PushEventHandler(pNotebookBackground); 
请教了,谢谢! :roll:
Cheshire Cat will get Summa Cum Laude.

>>>>>>>>>>>>>>>>>>>>>>>>>>>
OS: Windows XP Pro & Linux 2.6.16
Compiler: MSVC++ 6/MSVS 2005 & linux-g++/KDevelop
wxWindows 2.8.7

samggyy
Experienced Solver
Experienced Solver
Posts: 95
Joined: Wed Aug 15, 2007 7:34 am
Location: London, UK/ China
Contact:

Post by samggyy » Thu Dec 11, 2008 1:26 pm

矩阵在此,矩阵里的值在0到10之间(我将其值放大过,也没有用)。。。
Attachments
PhantomText64.txt
(36 KiB) Downloaded 151 times
Cheshire Cat will get Summa Cum Laude.

>>>>>>>>>>>>>>>>>>>>>>>>>>>
OS: Windows XP Pro & Linux 2.6.16
Compiler: MSVC++ 6/MSVS 2005 & linux-g++/KDevelop
wxWindows 2.8.7

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

Post by Utensil » Sun Dec 14, 2008 8:45 am

testImage是double **testImage,但wxImage的构造函数只接受unsigned char*。或许这是原因?

-Utensil
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/

Post Reply