gzlboy / imagelibrary

Automatically exported from code.google.com/p/imagelibrary
Other
0 stars 0 forks source link

KalikoImage constructor throws OutOfMemoryException when loading TIFF file #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. instantiate KalikoImage by passing TIFF file name

What is the expected output? What do you see instead?
Expected: image is instantiated properly
Actual: OutOfMemoryException is thrown

What version of the product are you using? On what operating system?
1.2.4.0 (Win7)

Please provide any additional information below.

This happens for some TIFF images (especially when they are about 1500x1500). 
What we have noticed it is related to some kind of unsupported format of image.

There is also a workaround for it. If conversion used in MakeImageNonIndexed() 
method is always executed, file is loaded properly:
private void MakeImageNonIndexed()
{
  //if(IndexedPalette)
    _image = new Bitmap(new Bitmap(_image));            
}

You can contact me at wojciech.kotlarski at 7digital.com in order to get 
example tiff file that is causing problems (I cannot upload this image with 
this ticket, as it should not be publicly available)

Original issue reported on code.google.com by wojciech...@7digital.com on 25 Feb 2013 at 2:51

GoogleCodeExporter commented 8 years ago
Hello,

There is a working code for us (change is applied to KalikoImage.cs):

public void LoadImage(string fileName)
{
    _image = ConvertImage(Image.FromFile(fileName));
    _g = Graphics.FromImage(_image);
}

public void LoadImage(Stream stream)
{
    _image = ConvertImage(Image.FromStream(stream));
    _g = Graphics.FromImage(_image);
}

/// <summary>
/// Convert image to truecolor
/// </summary>
private Image ConvertImage(Image image)
{
    using (image)
    using (Bitmap bitmap = new Bitmap(image))
        return new Bitmap(bitmap);
}

Original comment by wojciech...@7digital.com on 25 Feb 2013 at 5:02

GoogleCodeExporter commented 8 years ago

Original comment by fr3dr...@gmail.com on 25 Feb 2013 at 8:30