清除Byte变量的值 [英] Clearing a Byte variable's value

查看:105
本文介绍了清除Byte变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个存储图片的字节变量.如何清除此变量的值.#

谢谢

Hi,
I have a byte variable that stores picture. How to clear the value of this variable.#

Thanks

推荐答案

如何?
一个字节仅存储一个八位值. IE.它的整个值范围是0到255(包括0和255).非常少的图像将适合该空间.

如果您的意思是您有一个包含图像的字节数组,请为该变量分配一个新数组,然后垃圾回收器会在以后清除所有内容:
How?
A byte stores only a single eight bit value. I.e. it''s entire value range is 0 to 255 inclusive. Very, very few images will fit in this space.

If you mean you have an array of bytes, which contains an image, then assign a new array to the variable, and the Garbage Collector will clean it all up later:
myImageInByteArray = new byte(99) {}



如果您还有其他东西,那么我们需要更好的信息!

代码为



If you have something else all together, then we need better information!

"The code is

Dim vrPicture As Byte()
OpenFileDialog.Title = "Open picture file as your logo"
            OpenFileDialog.Filter = "Picture Files(*.jpg, *.gif)|*.jpg| |*.gif"
            OpenFileDialog.ShowDialog()
            vrPicture = IO.File.ReadAllBytes(OpenFileDialog.FileName)


现在vrPicture包含图片.对于下一条记录,我想清除其内存,而无需重新定义"


那不是你想做的.
我假设您实际要做的是将文件作为图像加载,清除现有图像并以相同的尺寸重复使用?如果是这样,则仅以字节读取文件将无济于事-JPG文件(和其他文件)已压缩,因此具有相同像素数的两张图片的字节大小将有所不同.

将文件读取为图像,然后清除该图像,或根据旧图像的大小创建一个新图像.如果要保存原始文件,我会选择后面的方法.


Now vrPicture contains the picture. For next record, I want to clear its memory, without re-defining"


That''s not quite what you want to do.
I assume that what you actually want to do is load a file as an image, clear the existing image and reuse it at teh same dimensions? If so, then just reading the file as bytes will not help - JPG files (and others) are compressed, so two pictures with the same number of pixels will be different sizes in terms of bytes.

Read the file as an Image, then either clear that Image, or create a new Image based on the size of the old one. I would go the later route, if you want to save over the original file.

Dim original As Image = Image.FromFile(path)
Dim newImage As Image = New Bitmap(original.Width, original.Height)
original.Dispose()


哇,整个怪胎!这样一来,我进行数学运算时,请等待一分钟,这是一张1 x 8像素的黑白图片.要回答您的问题,只需将0(零)分配给所述变量,就可以开始使用了!

干杯!
Wow a whole freaking byte! That would allow for, wait a minute while I do the maths, a 1 x 8 pixel black and white picture. And to answer your question, just assign 0 (zero) to said variable and you''re ready to go!

Cheers!


这篇关于清除Byte变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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