如何在asp.net Web应用程序中读取targa图像 [英] how to read targa image in asp.net web application
问题描述
我有一个targa图片,我想阅读并显示它.如何操作,我做了一些rnd
我找到了这段代码.
Hi,i have a targa image i want to read it and display it.how to do so,i did some rnd
i found this code.
// C# Sample
// Loads a targa image and assigns it to the Image of a picturebox control.
this.PictureBox1.Image = Paloma.TargaImage.LoadTargaImage(@"c:\targaimage.tga");
// Creates an instance of the TargaImage class with the specifed file
// displays a few targa properties and then assigns the targa image
// to the Image of a picturebox control
Paloma.TargaImage tgaImage = new Paloma.TargaImage(@"c:\targaimage.tga");
this.Label1.Text = tgaImage.Format.ToString();
this.Label2.Text = tgaImage.Header.ImageType.ToString();
this.Label3.Text = tgaImage.Header.PixelDepth.ToString();
this.PictureBox1.Image = Paloma.TargaImage.Image;
但是在这里他们使用了web应用程序中不存在的图片框,在这里我认为他们使用了window应用程序.我想在web应用程序中显示图像,我应该使用哪个控件,asp:image control?那我怎么用它来绑定targa图像,
我应该使用handler.ashx吗????一旦我使用asp:image控件和handler.ashx显示jpeg图像,但是在这种情况下,我该怎么做,请给我一点帮助.
but here they have used picture box which is not present in web application,here i think they have used window application .i want to show image in web application,which conrtrol should i use ,asp:image control?? then how will i use it to bind targa image,
should i have to use handler.ashx???once i have display a jpeg image using asp:image control and handler.ashx,but in this case how can i do so,plz help.
推荐答案
尝试一下,
从 .NET Targa图像阅读器下载源代码 [
Try this,
Download the source from .NET Targa Image Reader[^]
Include the TargaImage.dll in bin folder and reference it to the project,
In aspx code,
<asp:Image ID="Image1" ImageUrl="~/Handler.ashx" runat="server" />
在Handler.ashx,
中
using System.Drawing;
In Handler.ashx,
using System.Drawing;
Bitmap tga = Paloma.TargaImage.LoadTargaImage(@"C:/my folder/TargaReaderDemo/Image/img.tga");
Response.ContentType = "image/jpeg";
tga.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
请参阅此CodeProject文章: ^ ].
—SA
Please see this CodeProject article: .NET Targa Image Reader[^].
—SA
这篇关于如何在asp.net Web应用程序中读取targa图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!