My requirements specify the image must be 72.009 DPI and have a bit depth of 8-bits, and if an image does not match these requirements, then I am to convert it so it does. I am having difficulty taking a BMP image that has a vertical and horizontal DPI of 71.9836 and setting it to 72.009 without the color depth changing from 8-bits (256 colors) to 24-bit (8-bits per channel). The 24-bit image looks just like the original, but doesn't meet my requirements. If I call ConvertTo8BppQ, then the image can be saved as an 8-bit depth image successfully. However, this causes banding (stair casing) in the image. Could you please advise how I can set an image from 71.9836 DPI (vertical and horizontal) to 72.009 DPI and 8-bit depth without this banding effect? The original image I am changing the DPI for is at an 8-bit depth already - all I am trying to change is the DPI. I have attached to sample files. PARJFK05.BMP is the original file, and the PARJFK05-test.BMP is the resulting "banded" image after getting the original to meet my specifications I was given. Source code is below that I am using.
- Code: Select all
Dim objGdP As GdPicture.GdPictureImaging = Nothing
objGdP = New GdPicture.GdPictureImaging()
objGdP.SetLicenseNumber(GdPictureLicense)
Dim strSrcFile As String = "C:\DevTest\GdPicture\PARJFK05.BMP"
Dim intImageID As Integer = objGdP.CreateGdPictureImageFromFile(strSrcFile)
Dim fltHRes As Single = objGdP.GetHorizontalResolution(intImageID)
Dim fltVRes As Single = objGdP.GetVerticalResolution(intImageID)
Dim fltDPIResolution As Single = 72.009
objGdP.SetHorizontalResolution(intImageID, fltDPIResolution)
objGdP.SetVerticalResolution(intImageID, fltDPIResolution)
objGdP.ConvertTo8BppQ(intImageID, 256)
Dim strDstFile As String = "C:\DevTest\GdPicture\PARJFK05-test.BMP"
If (File.Exists(strDstFile)) Then
File.Delete(strDstFile)
End If
objGdP.SaveAsBMP(intImageID, strDstFile)
objGdP.ReleaseGdPictureImage(intImageID)
objGdP.ClearGdPicture()