Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, May 16, 2011 12:18:49 AM(UTC)
terry.bogard

Groups: Registered
Posts: 18


Hello!!
I'm  using leadtools 17 I would like to know how to convert with leadtools an OLD JPEG IN TIFF image in System.Drawing.Bitmap and then streaming it to asp:image control.

please help.

Thank You!.


 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, May 16, 2011 4:19:38 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

Terry,
If you want to load an image of any format (including TIFF JPEG variations) into a System.Drawing.Image, you can simply use our RasterCodecs.Load() method to load your file, then call the RasterImageConverter. ConvertToImage() method. For details and code sample, please see the RasterImageConverter Class help topic. Also available on this page:
http://www.leadtools.com/Help/LEADTOOLS/v17/DH/ld/leadtools.drawing~leadtools.drawing.rasterimageconverter.html

About streaming, we have our own web image viewer so if you want to use the Microsoft Bitmap object, you can't use it with LEADTOOLS directly. You can however use our own objects for web display. For details, see the WebFormsDemo shipped with our toolkit.
You can find the demo source code in this folder location:
[LEADTOOLS 17 folder]\Examples\DotNet\CS\WebFormsDemo
 
#3 Posted : Monday, May 16, 2011 5:43:06 AM(UTC)
terry.bogard

Groups: Registered
Posts: 18


Thank You Adnan,
but I don't have to convert a TIFF in JPEG but I
have to stream TIFF File that have inside a JPEG structure (the famous OLD JPEG in TIFF)
can you please provide to me a example how to stream this kind of file to leadtools WebImageViewer ?
for the normal tiff and the Microsoft asp:image I can do this..

System.IO.Stream _stream = new System.IO.FileStream("C:\myImage.tiff", System.IO.FileMode.Open);
        try
        {
            Bitmap _bmp = new Bitmap(_stream);
            Context.Response.ContentType = "image/gif"; //no problem if jpeg,png etc etc
            _bmp.Save(Context.Response.OutputStream, ImageFormat.Gif); // no problem if jpeg, png etc etc..
            _bmp.Dispose();
            _stream.Close();
        }

I want be able to do the same with this kind of TIFF file that with the Bitmap class go in "out of memory exception".

please help me.

Thank You for your support.

Terry.
 
#4 Posted : Tuesday, May 17, 2011 5:41:33 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

Terry,
Your code snippet above is actually performing a conversion from TIFF to GIF. However, since the MS classes do not support TIFF/JPEG (a.k.a. JTIF), this code will not work with JTIF images.

On the other hand, our toolkit can load and save almost all types and subtypes of TIFF, including JTIF. They also support saving to stream, so you should be able to use code like this at the server side:

RasterCodecs _codecs = new RasterCodecs();
RasterImage img = _codecs.Load(@"C:\myImage.tiff");
_codecs.Save(img, outputStream, RasterImageFormat.Gif, 8); // or any web-friendly format such as JPEG 24 bits or PNG.

Using this code, you can actually load and convert to web formats from all file formats supported by our toolkit, of which there are dozens. Of course you will need some of our DLLs on the server, depending on which formats you want to support. For a detailed list, see the help topic "Files to be Included with Your Application".
 
#5 Posted : Tuesday, May 17, 2011 6:06:34 AM(UTC)
terry.bogard

Groups: Registered
Posts: 18


Hello Adnan
Thank You for your help.
I can sucessfully stream the image now thank you
but with this code image change drastically :(

MemoryStream _stream = new MemoryStream();
        RasterCodecs _codecs = new RasterCodecs();
        RasterImage img = _codecs.Load(_percorsoFile);
        _codecs.Save(img, _stream, RasterImageFormat.Gif, 8);
        Bitmap _bmp = new Bitmap(_stream);
        Context.Response.ContentType = "image/gif";
        _bmp.Save(Context.Response.OutputStream, ImageFormat.Gif);

I don't know why but the image looks orrible :(

Please help me.
 
#6 Posted : Wednesday, May 18, 2011 5:24:14 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

This could be related to the original image's color content. The GIF format does not support full color. It only supports up to 8 bits per pixel (maximum of 256 unique colors). If your original image has more colors, consider saving to the stream using 24-bits PNG or JPEG (RasterImageFormat.Png, Jpeg, Jpeg411 or Jpeg422).
 
#7 Posted : Wednesday, May 18, 2011 5:57:18 AM(UTC)
terry.bogard

Groups: Registered
Posts: 18


OK !! I got it..
thank you!

but now.. how I can steam the image to  WebThumbnailViewer because seems that it can load only phisically the file with the load method ?
I need to stream to this object because I will load the image from a non virtual path, and I can't use the load method.


Thank you for all of your help.
 
#8 Posted : Thursday, May 19, 2011 6:29:40 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)

What do you mean exactly by "non virtual path"?
In your original code, you saved the MS Bitmap object to a Context.Response.OutputStream. If you want to do the same thing using LEADTOOLS, simply call our RasterCodecs.Save(stream, ...) method.

If you're trying to do something else, please give exact details about the source file location, the LEADTOOLS object(s) you're using, where they are being instantiated (client, server, etc.), and where everything is being executed.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.196 seconds.