3

I have a 3600*3600 pixel png file

enter image description here

that I am trying to save as a bmp using this code

var bmpSource = Path.ChangeExtension(source, "bmp");
lock (FileAccessString)
{
    if (!File.Exists(bmpSource))
    {
        var dummy = Image.FromFile(source);
        dummy.Save(bmpSource, ImageFormat.Bmp);
    }
}

The result is

enter image description here

which is pretty close, but there are areas visible to the eye (particularly on the left-hand side) that are not correct.

What could be causing this weird artifact?

DefenestrationDay
  • 3,712
  • 2
  • 33
  • 61
  • 3
    Could they be transparent pixels in the original? – Steve May 26 '14 at 09:39
  • Side note: [don't lock an strings](http://stackoverflow.com/questions/12804879/is-it-ok-to-use-a-string-as-a-lock-object). – Sriram Sakthivel May 26 '14 at 09:41
  • I downloaded first image, then used your same code. It works fine for me. No mismatch in pixels. Not sure why!! – Sriram Sakthivel May 26 '14 at 09:47
  • @Steve: Every pixel has a 0x5F transparency – DefenestrationDay May 26 '14 at 09:54
  • 1
    Can you give a link to the original file? This small copy doesn't have anything peculiar in the regions of the artifacts. Also: Do make sure about transparency pixels Steve noted!! These will not work in BMP files! – TaW May 26 '14 at 09:55
  • @TaW: Done - http://s1.uploads.im/yRpra.png – DefenestrationDay May 26 '14 at 10:11
  • 1
    Hm, this is clean (of tranparent pixels) as well. And like Sriram Sakthivel says: Your code works just fine without any artifacts. (Without the undefined Lock(FileAccessString), thoigh).. It is reproducable? Does it happen with other images?? – TaW May 26 '14 at 10:23
  • 1
    Can you also upload your result BMP? – Jongware May 26 '14 at 17:29
  • `pngcheck` shows the original PNG uses various filters: `up`, `sub`, `avg`, and [`paeth`](http://www.w3.org/TR/PNG-Filters.html#Filter-type-4-Paeth). In particular, that last one is tricky to implement -- see the **Note** in the specifications. It looks like there is a small error in .net's implementation, but without the result BMP it's hard to pin down where exactly. – Jongware May 30 '14 at 23:21

0 Answers0