如何查看位图是否有效(不为null) [英] How to see the bitmap is valid (not null)

查看:131
本文介绍了如何查看位图是否有效(不为null)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问点事.也许这是一个愚蠢的问题,但是这个错误给我带来了很多麻烦.
我想从字节数组创建一个表示图片的BGR颜色的位图图像.我使用的是 http://social.msdn. microsoft.com/Forums/zh-CN/vblanguage/thread/da967cea-7e57-4065-9ce9-f7810341aeff [

hi guys, I want to ask something. Maybe it is a silly question but I got a lot of trouble from this error.
I want to create a bitmap image from byte array that represent the BGR color of the picture. I use this reference http://social.msdn.microsoft.com/Forums/en-NZ/vblanguage/thread/da967cea-7e57-4065-9ce9-f7810341aeff[^] the original author says that the function is okay. But, when I convert it to C#, I got may project was froze. And I use the breakpoint to see whether the bitmap that I have created was valid or not, but I dont know what should I looked to? is it the rawdata? or what is it?

推荐答案

两件事:

1.在尝试使用字节数组之前,请先对其进行确认.确保它不为null,并检查长度以确保有足够的字节来完成图像.

2.您是否在线程末尾使用了代码(它在C#中)?对原始帖子进行了编辑,建议使用该线程末尾的代码,而不是一个标记为答案的代码.
Two things:

1. Definitely validate your byte array before trying to use it. Make sure it is not null and perhaps check the length to ensure there are enough bytes to complete the image.

2. Did you use the code at the end of the thread(it is in C#)? The original post was edited to recommend that the code at the end of the thread be used, not the one marked answer.


这篇关于如何查看位图是否有效(不为null)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆