使用后释放位图 [英] Releasing a bitmap after use

查看:76
本文介绍了使用后释放位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个包含PictureBox控件的Windows应用程序。我正在使用

声明


PicBox.Image = new Bitmap(" C:\Pic.jpg");


将文件加载到要显示的PictureBox中。


我使用定时器控件来旋转我显示的图片Pic0 - Pic9

每30秒。


但是,当我将图片更改为序列中的下一张图片时,

旧图片不是 ;发布"并且Windows将不允许我编辑

名称等,直到整个应用程序关闭。


如何删除与图像文件的连接我不再希望

在我的PictureBox中显示它,以便可以在我的

应用程序之外编辑该文件。


非常感谢提前

Hi,

I have a windows application that contains a PictureBox control. I am using
the statement

PicBox.Image = new Bitmap ("C:\Pic.jpg");

to load a file into the PictureBox to be displayed.

I am using a timer control to rotate the pictures that I display Pic0 - Pic9
every 30 seconds.

However, as I change the picture to the the next one in the sequence, the
old picture is not being "released" and windows will not allow me to edit the
name etc until the entire application is closed down.

How do I drop the connection to the image file when I no longer wish to
display it in my PictureBox so that the file can be edited outside of my
application.

Many thanks in advance

推荐答案




图像仍在使用中。这样做,预加载数组中的所有图像然后

将它们旋转到图片框


另外我会考虑使用单个动画gif

-

-

Ignacio Machin,

ignacio.machin at dot.state.fl.us
佛罗里达州交通局


" hplloyd" < hp ***** @ discussion.microsoft.com写信息

新闻:0D *********************** *********** @ microsof t.com ...
Hi,

The image is still in use. Do this, preload all the images in an array then
rotate them to the picturebox

Also I would consider the use of a single animated gif
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"hplloyd" <hp*****@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...




我有一个包含PictureBox控件的Windows应用程序。我是

使用

声明


PicBox.Image = new Bitmap(" C:\Pic.jpg" );


将文件加载到要显示的PictureBox中。


我正在使用计时器控件来旋转我显示的图片Pic0 -

Pic9
每30秒



然而,当我将图片更改为序列中的下一张图片时,

旧图片未被发布。和Windows将不允许我编辑



名称等,直到整个申请被关闭。


我如何当我不想再将
显示在我的PictureBox中时,删除与图像文件的连接,以便可以在我的

应用程序之外编辑该文件。


非常感谢提前
Hi,

I have a windows application that contains a PictureBox control. I am
using
the statement

PicBox.Image = new Bitmap ("C:\Pic.jpg");

to load a file into the PictureBox to be displayed.

I am using a timer control to rotate the pictures that I display Pic0 -
Pic9
every 30 seconds.

However, as I change the picture to the the next one in the sequence, the
old picture is not being "released" and windows will not allow me to edit
the
name etc until the entire application is closed down.

How do I drop the connection to the image file when I no longer wish to
display it in my PictureBox so that the file can be edited outside of my
application.

Many thanks in advance



尝试使用文件流加载图片


uisng(FileStream fs = new

FileStream(@" C:\Pic.jpg",FileMode.Open,FileAccess.Read,FileShare.Read))

{

PicBox.Image = Image.FromStream(fs);

}

" hplloyd" < hp ***** @ discussion.microsoft.com写信息

新闻:0D *********************** *********** @ microsof t.com ...
Try loading the picture using a filestream

uisng (FileStream fs = new
FileStream(@"C:\Pic.jpg",FileMode.Open,FileAccess. Read,FileShare.Read))
{
PicBox.Image = Image.FromStream(fs);
}
"hplloyd" <hp*****@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...




我有一个包含PictureBox控件的Windows应用程序。我是

使用

声明


PicBox.Image = new Bitmap(" C:\Pic.jpg" );


将文件加载到要显示的PictureBox中。


我正在使用计时器控件来旋转我显示的图片Pic0 -

Pic9
每30秒



然而,当我将图片更改为序列中的下一张图片时,

旧图片未被发布。和Windows将不允许我编辑



名称等,直到整个申请被关闭。


我如何当我不想再将
显示在我的PictureBox中时,删除与图像文件的连接,以便可以在我的

应用程序之外编辑该文件。


非常感谢提前
Hi,

I have a windows application that contains a PictureBox control. I am
using
the statement

PicBox.Image = new Bitmap ("C:\Pic.jpg");

to load a file into the PictureBox to be displayed.

I am using a timer control to rotate the pictures that I display Pic0 -
Pic9
every 30 seconds.

However, as I change the picture to the the next one in the sequence, the
old picture is not being "released" and windows will not allow me to edit
the
name etc until the entire application is closed down.

How do I drop the connection to the image file when I no longer wish to
display it in my PictureBox so that the file can be edited outside of my
application.

Many thanks in advance



感谢您的帮助,但预加载它们实际上对我的帮助不大

情况。 (我给出的例子不是我的真实例子,只是一个子集




有什么方法可以释放图像,这样我完成显示后不再使用




Ignacio Machin(.NET / C#MVP)"写道:
Thanks for your help however pre-loading them will not actually help in my
circumstances. (the example I gave is not my real life example, just a subset
of it)

Is there any way that I can release an image so that it is no longer in use
after I have finished displaying it?

"Ignacio Machin ( .NET/ C# MVP )" wrote:




图像仍在使用中。这样做,预加载数组中的所有图像然后

将它们旋转到图片框


另外我会考虑使用单个动画gif


-

-

Ignacio Machin,
ignacio.machin at dot.state.fl。我们

佛罗里达州交通局


" hplloyd" < hp ***** @ discussion.microsoft.com写信息

新闻:0D *********************** *********** @ microsof t.com ...
Hi,

The image is still in use. Do this, preload all the images in an array then
rotate them to the picturebox

Also I would consider the use of a single animated gif
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"hplloyd" <hp*****@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...




我有一个包含PictureBox控件的Windows应用程序。我是

使用

声明


PicBox.Image = new Bitmap(" C:\Pic.jpg" );


将文件加载到要显示的PictureBox中。


我正在使用计时器控件来旋转我显示的图片Pic0 -

Pic9
每30秒



然而,当我将图片更改为序列中的下一张图片时,

旧图片未被发布。和Windows将不允许我编辑



名称等,直到整个申请被关闭。


我如何当我不想再将
显示在我的PictureBox中时,删除与图像文件的连接,以便可以在我的

应用程序之外编辑该文件。


非常感谢提前
Hi,

I have a windows application that contains a PictureBox control. I am
using
the statement

PicBox.Image = new Bitmap ("C:\Pic.jpg");

to load a file into the PictureBox to be displayed.

I am using a timer control to rotate the pictures that I display Pic0 -
Pic9
every 30 seconds.

However, as I change the picture to the the next one in the sequence, the
old picture is not being "released" and windows will not allow me to edit
the
name etc until the entire application is closed down.

How do I drop the connection to the image file when I no longer wish to
display it in my PictureBox so that the file can be edited outside of my
application.

Many thanks in advance






这篇关于使用后释放位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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