获取图像的处理在C#内存 [英] Get Handle of an Image in memory in C#
问题描述
我有一个函数,它在处理
来的图像:
DoSomethingWithImage(INT imageHandle)
{
}
在我的主,我有一个图像MYIMAGE
,它驻留在内存中。
我如何获得处理
到 MYIMAGE
,这样我可以在<$ C $传C>处理到 DoSomethingWithImage()
?
的main()
{
// MemoryStream的是一个byte []
图像MYIMAGE = Image.FromStream(MemoryStream的,真正的);
DoSomethingWithImage(???);
}
图片
只是一个抽象基类;后代不一定能够保证即使的有无的一个Windows句柄。你需要知道特定类型的图像 - 也是如此你使用的SDK,最有可能的;它可能是假定手柄对应于特定的格式(我猜位图)。
如果图像实际上是一个位图
,那么你将要使用的 Bitmap.GetHbitmap 方法。在另一方面,如果该图像确实是一个图元文件
,那么你需要使用的 Metafile.GetHenhmetafile 方法得到的句柄。
I have a function that takes in a Handle
to an image:
DoSomethingWithImage( int imageHandle)
{
}
In my main, I have an Image myImage
, which resides in memory.
How can I get a Handle
to myImage
, so that I can pass in that Handle
to DoSomethingWithImage()
?
main()
{
//memorySTream is a byte[]
Image myImage = Image.FromStream(memoryStream, true);
DoSomethingWithImage( ??? );
}
Image
is just the abstract base class; descendants aren't necessarily guaranteed to even have a Windows handle. You need to know the specific type of image - and so does the SDK you're using, most likely; it is probably assuming that the handle corresponds to a specific format (I would guess bitmap).
If the image is in fact a Bitmap
, then you would want to use the Bitmap.GetHbitmap method. On the other hand, if the image is really a Metafile
, then you need to use the Metafile.GetHenhmetafile method to get a handle.
这篇关于获取图像的处理在C#内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!