1

I've searched lots of webpages, forums and other resources over the web and these two simple lines of code still drive me crazy:

Dim ImageFile As FileStream = File.Open("C:\Programowanie\Indeksowanie\01.tif", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
ImageBox.Image = CType(Bitmap.FromStream(ImageFile), Bitmap)

When run on Win 7 or 8 it works perfectly fine. The picture box displays full 32bit colors. When run on Win XP the image quality goes dramatically down (only black and white) what is unacceptable. Any ideas for workaround? I cannot convert to jpegs as I need to handle multipage scanned document (business requirement).

4

1 回答 1

0

Eventually I've got it. The results are not 100% what I expected but are acceptable and the effect displayed on the screen is much more better than previously. Here's a piece of code:

    Dim fs As FileStream = File.Open("C:\Programowanie\Indeksowanie\01.tif", FileMode.Open, FileAccess.Read)
    Dim bm As Bitmap = CType(Bitmap.FromStream(fs), Bitmap)
    Dim temp As New Bitmap(bm.Width, bm.Height)
    Dim g As Graphics = Graphics.FromImage(temp)
    Dim ScaledWidth As Integer = CInt(Math.Round((ImageBox.Height / bm.Height) * bm.Width))

    g.InterpolationMode = InterpolationMode.HighQualityBicubic
    g.CompositingQuality = CompositingQuality.HighQuality
    g.DrawImage(bm, 0, 0, ScaledWidth, ImageBox.Height)
    ImageBox.Image = temp
于 2013-04-13T19:49:43.297 回答