LB Booster
« Size of a BMP Image »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:05am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Size of a BMP Image  (Read 417 times)
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Size of a BMP Image
« Thread started on: Oct 2nd, 2015, 5:49pm »

Does anyone know how to determine the pixel dimensions of a .BMP image so it can be centered with the DrawBMP command if desired?
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Size of a BMP Image
« Reply #1 on: Oct 2nd, 2015, 6:14pm »

http://lbpe.wikispaces.com/GraphicDimensions
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Size of a BMP Image
« Reply #2 on: Oct 2nd, 2015, 7:42pm »

on Oct 2nd, 2015, 5:49pm, Jack Kelly wrote:
Does anyone know how to determine the pixel dimensions of a .BMP image so it can be centered with the DrawBMP command if desired?

Here you go:

Code:
    loadbmp "bitmap", "myimage.bmp"
    hbitmap = hbmp("bitmap")
    struct bitmap, bmType as long, bmWidth as long, bmHeight as long, _
      bmWidthBytes as long, bmPlanes as short, bmBitsPixel as short, _
      bmBits as ulong
    bitmaplen = len(bitmap.struct)
    calldll #gdi32, "GetObjectA", hbitmap as ulong, _
      bitmaplen as long, bitmap as struct, ret as long
    print "Width is "; bitmap.bmWidth.struct
    print "Height is "; bitmap.bmHeight.struct 

I'm personally not keen on methods that involve peeking the file, and since you're likely to want to loadbmp the image anyway the above method seems more direct.

Richard.
« Last Edit: Oct 2nd, 2015, 7:45pm by Richard Russell » User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Size of a BMP Image
« Reply #3 on: Oct 3rd, 2015, 07:01am »

Thank you both for your suggestions. Both methods look good to me. As always, your help is greatly appreciated.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls