Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bitmap handler
#11
Ok i modded yours to accept widths that are not multiples of 4, its still only 24 bit

This code handles the padding..

Code:
If ((bmp_header.biWidth * 3) AND 3) <> 0 Then
      p += 4 - ((bmp_header.biWidth * 3) AND 3)
    End If

Code:
Type bitmap_header Field = 1
  bfType          As uShort
  bfsize          As uInteger
  bfReserved1     As uShort
  bfReserved2     As uShort
  bfOffBits       As uInteger
  biSize          As uInteger
  biWidth         As uInteger
  biHeight        As uInteger
  biPlanes        As uShort
  biBitCount      As uShort
  biCompression   As uInteger
  biSizeImage     As uInteger
  biXPelsPerMeter As uInteger
  biYPelsPerMeter As uInteger
  biClrUsed       As uInteger
  biClrImportant  As uInteger
End Type

Dim bmp_header As bitmap_header
Dim p As Integer

  Open "infile.bmp" For Binary As #1
    Get #1, , bmp_header
    Redim image(0 To bmp_header.biSizeImage - 1) As uByte
    Get #1, , image()
  Close #1
  
  Screenres 320, 200, 24
  
  For y = (bmp_header.biHeight - 1) To 0 Step -1
    For x = 0 To bmp_header.biWidth - 1
      PSet(x, y), RGB(image(p + 2), image(p + 1), image(p))
      p += 3
    Next x
    If ((bmp_header.biWidth * 3) AND 3) <> 0 Then
      p += 4 - ((bmp_header.biWidth * 3) AND 3)
    End If
  Next y
  Sleep
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)