Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #1752

Re: Problem with loading a 256 color bitmap (using the hard way)

From Schmidt <ng@vbRichClient.com>
Newsgroups comp.lang.basic.visual.misc
Subject Re: Problem with loading a 256 color bitmap (using the hard way)
Date 2013-03-22 23:55 +0100
Organization Aioe.org NNTP Server
Message-ID <kiinin$1al$1@speranza.aioe.org> (permalink)
References <kihqkp$n6u$1@dont-email.me>

Show all headers | View raw


Am 22.03.2013 15:44, schrieb Paulo:

> I can't understand the problem with this function.
 > ...
> Public Function Load_BMP256( _
 > ...

You over-complicated things.

I mean, come on - 285 lines of code for something the
LoadPicture-Function can solve in one line? ;-)

Ok, you perhaps need this for a game-engine or something,
since you want to restrict to 8bpp-Bitmaps with a 256-
Color-Palette only - but even then you can reduce your
code-volume about factor 10..., tried to keep all your
error-raising-stuff intact, including the FileNotExists -
error, which is implicitely raised by the FileLen-Function.

'***Into a Form
Option Explicit

Private Sub Form_Click()
   Set Me.Picture = Load_BMP256("d:\8bpp.bmp")
End Sub

Public Function Load_BMP256(ByVal FileName As String) As IPictureDisp
Dim FNr&, FLen&, BMSig As String * 2, BMSize&, BMBits%

   FileName = Trim$(FileName)
   FLen = FileLen(FileName)

   FNr = FreeFile
   Open FileName For Binary Access Read As FNr
     Get FNr, , BMSig
     Get FNr, , BMSize
     Get FNr, 29, BMBits
   Close FNr

   'Check for the file type signature 'BM':
   If BMSig <> "BM" Then Err.Raise 321& 'Invalid FileFormat

   'Confirm file size:
   If BMSize <> FLen Then Err.Raise 321& 'Invalid FileFormat

   'Check for valid bits per pixel:
   Select Case BMBits
     Case 1, 4, 16, 24, 32
     Err.Raise vbObjectError + 1, , "The application does not support " _
                                  & BMBits & "-bit bitmaps"
   End Select

   Set Load_BMP256 = LoadPicture(FileName)
End Function

Olaf

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem with loading a 256 color bitmap (using the hard way) "Paulo" <pmpcosta.nospam@netcabo.pt> - 2013-03-22 14:44 +0000
  Re: Problem with loading a 256 color bitmap (using the hard way) Schmidt <ng@vbRichClient.com> - 2013-03-22 23:55 +0100
    Re: Problem with loading a 256 color bitmap (using the hard way) "Paulo" <nospam.vbstudent@syscolor.net> - 2013-03-23 00:18 +0000
      Re: Problem with loading a 256 color bitmap (using the hard way) Schmidt <ng@vbRichClient.com> - 2013-03-23 04:21 +0100
        Re: Problem with loading a 256 color bitmap (using the hard way) "Paulo" <nospam.vbstudent@syscolor.net> - 2013-03-23 21:11 +0000

csiph-web