如何在MFC中从2D数组绘制图片? [英] How to draw the picture from 2D Array in MFC?
本文介绍了如何在MFC中从2D数组绘制图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
i希望在VC ++中生成一个数值为Array [1024] [1024]的2D数组的图像(Bitmap),每个值都是从0到255的RGB。是否有任何VC ++函数要做这个?
先谢谢。
Hi
i want to generate in VC++ an image (Bitmap) from a 2D array of numerical value Array[1024][1024] that each value is a RGB from 0 to 255. is there any VC++ function to do this?
Thanks in Advance.
推荐答案
看看SetDIBitsToDevice
Win32功能:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162974(v=vs.85).aspx
这是一个非常古老的,我曾经做过同样的工作 - 我有一个8位信号强度的二维数组,并映射到一个托盘的颜色。在你的情况下,颜色将是灰度,但没有理由他们需要。
我能想到的一个问题 - 数据会必须是4字节宽的倍数,但是因为你的数据是1024x1024,这没问题。
另一个是我似乎记得它将图像颠倒了,但你可以玩用坐标来看它是如何工作的。
MSDN声称来自Win2000的支持,但我在Windows 3.1中使用这个功能,所以它非常古老,非常好极了,非常强大。
祝你好运!
Iain。
Have a look atSetDIBitsToDevice
Win32 function:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162974(v=vs.85).aspx
It''s a very old one, and one I used to do the same job you are doing - I had a 2d array of 8bit signal strength, and that mapped to a pallette of colours. In your case, the colours will be greyscale, but there''s no reason they need to be.
One "gotcha" I can think of - the data will have to be a multiple of 4 bytes wide, but as your data is 1024x1024, that''s no problem.
Another is that I seem to remember it painting the image upside down, but you can play with the coordinates to see how it works.
MSDN claims support from Win2000, but I was using this function in Windows 3.1, so it''s very ancient, very tricky, and very powerful.
Good luck!
Iain.
>
这篇关于如何在MFC中从2D数组绘制图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文