Save image - bit depth?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    Save image - bit depth?

    [code=vbnet]
    Private Sub SaveResized()

    Dim bm As New Bitmap(PictureB ox1.Image)

    Dim myX As Integer

    Dim myY As Integer

    myX = 640

    myY = 480

    If myY = 0 Or myX = 0 Then Exit Sub Else

    Dim thumb As New Bitmap(myX, myY)

    Dim g As Graphics = Graphics.FromIm age(thumb)

    g.Interpolation Mode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c

    g.DrawImage(bm, New Rectangle(0, 0, myX, myY), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pi xel)

    g.Dispose()

    Dim message, title, defaultValue As String

    'Dim myValue As String

    'message = "Enter File Name:" ' Set prompt.

    'title = "Save Resized Photo" ' Set title.

    defaultValue = "" ' Set default value.

    'get name to save resized image, using Inputbox

    'myValue = InputBox(messag e, title, defaultValue)

    'If myValue = "" Then bm.Dispose() : thumb.Dispose() : Exit Sub Else

    thumb.Save("C:\ temp\Boot.bmp", System.Drawing. Imaging.ImageFo rmat.Bmp)

    bm.Dispose()

    thumb.Dispose()

    'Dim caption As String = "Save Resized Photo"

    'MessageBox.Sho w("The Resized Photo has been saved as: " & i, caption, MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

    End Sub
    [/code]

    The code above formats the image in my picturebox and saves it accordingly.
    Problem - The image bit depth is 32
    i want it to be 16

    can any1 help?

    James
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Have you tried adding in somewhere the following line:
    [code=vbnet]
    thumb.PixelForm at = PixelFormat.For mat16bppRgb555
    [/code]

    You may want to check under the PixelFormat to see if there is on you like better.

    Comment

    • jamesd0142
      Contributor
      • Sep 2007
      • 471

      #3
      fixed it thanks...

      changed line 15 above to:

      [code=vbnet]
      Dim thumb As New Bitmap(myX, myY, Imaging.PixelFo rmat.Format16bp pRgb555) '----
      [/code]

      Comment

      Working...