Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;


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.
Posted
Comments
Kenneth Haugland 2-Aug-12 23:28pm    
Its WinForms alright... Why dont you try out some controls and see what works :) If you get stuck tell us were you are stuck. Your question seems to imply that you need permission from us before you try it out. You dont :)
software_Engi08 3-Aug-12 1:09am    
<asp:Image ID="Image1" ImageUrl="~/Handler.ashx" runat="server" />
in the handler i write code as
Paloma.TargaImage tgaImage = new Paloma.TargaImage("C:/my folder/TargaReaderDemo/Image/img.tga");
context.Response.ContentType = "image/tga";
context.Response.BinaryWrite(byteArray);
context.Response.End();
but not working ????
software_Engi08 3-Aug-12 1:10am    
Paloma.TargaImage tgaImage = new Paloma.TargaImage("C:/my folder/TargaReaderDemo/Image/img.tga");
context.Response.ContentType = "image/tga";
context.Response.BinaryWrite(tgaImage );
context.Response.End();
but not working ????

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,
C#
<asp:Image ID="Image1" ImageUrl="~/Handler.ashx" runat="server" />


In Handler.ashx,
using System.Drawing;
C#
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);
 
Share this answer
 
v2
Please see this CodeProject article: .NET Targa Image Reader[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900