Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
yet another question =P
#1
Code:
type BMPHeaderInfo
    BIid as string*2
    BIfilesize as long
    BIreserved as integer
    BIreserved2 as integer
    BIoffset as long
    BIheadersize as long
    BIwidth as long
    BIheight as long
    BIplanes as integer
    BIbpp as integer
    BIcompressionfactor as long
    BIimagesize as long
    BIpelwidth as long
    BIpelheight as long
    BIcolorused as long
    BIimportantcolors as long
end type

type RGBQuad
    b as byte
    g as byte
    r as byte
    pad as byte
end type

dim header as BMPHeaderInfo
dim colors(255) as RGBQuad

open "whatever.bmp" for binary as #1

    get #1,, header

    for grabcolors = 0 to 255
        get #1,, colors(grabcolors)
    next

close #1

while inkey$ = "":wend

can anyone tell me why this isnt working, i get strange output when i check the variables in the header after loading a bmp...
Reply
#2
Hey, maybe you can try using Field = 1 (Type udtname Field = 1) to get rid of padding. If could work.
Reply
#3
also interger in FB are 4 byte's and longs are aliased intergers.
for 2 byte intergers use short


also field 1 to get ride of padding although you might not need to.
Reply
#4
it is a problem with the type

Code:
type BMPHeaderInfo 'field = 1
    BIid as string*2
    BIfilesize as long
    BIreserved as short
    BIreserved2 as short
    BIoffset as long
        
    BIheadersize as long
    BIwidth as integer
    BIheight as integer
    BIplanes as short
    BIbpp as short
    BIcompressionfactor as long
    BIimagesize as long
    BIpelwidth as long
    BIpelheight as long
    BIcolorused as long
    BIimportantcolors as long
end type

type RGBQuad
    b as byte
    g as byte
    r as byte
    pad as byte
end type

dim header as BMPHeaderInfo
dim colors(255) as RGBQuad

open "e:\mydocu~1\mp3_icon.bmp" for binary as #1

    get #1,, header

    for grabcolors = 0 to 255
        get #1,, colors(grabcolors)
    next
    get #1,19,wid%
    get #1,23,hei%
    
close #1


? header.BIwidth
? header.BIheight
? wid%
?hei%
while inkey$ = "":wend

after applying this quick hack to read the width and height value directly from their respective offset, i came up with the right results in wid% and hei% ONLY

field = 1 gives me erratic answers as well

so... any ideas? Tongue
Reply
#5
Declare BIid as short or string * 2-1, FB fixed-len strings are nul-terminated, what needs a char more than the len given.
Reply
#6
o0o thank you very much =)

worked with field = 1

i was wondering why when i read the id it was BMand then a weird ascii char :oops:
Reply
#7
If you're using the built-in FB gfxlib, you can forget about BMP loading; I just added to CVS BMP loading support to BLOAD, so you can just do
Code:
DIM image(64004) AS UBYTE
SCREEN 13
BLOAD "image.bmp", VARPTR(image(0))
PUT (0,0), image
ngelo Mottola - EC++
Reply
#8
Quote:Declare BIid as short or string * 2-1, FB fixed-len strings are nul-terminated, what needs a char more than the len given.

Victor:
Declaring as string *2-1 will preserve the right amount of space to GET the header correctly, but the \0 will not be created. What happens if i try to assign the string to a truestring? Perhaps it will leak?
Antoni
Reply
#9
You could do something like

Get #FileNumber, , VariableName

VariableName = VariableName + CHR$(0)

to null terminate the string properly.
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)