Qbasicnews.com

Full Version: using an existing bitmap
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
there must be a way to import an existing bitmap, the one i want and there will be more, is 16x16, that would be 256 PSET commands, like cmon, that would take forever, unless theres an easier way, this is the img, the lite blu parts will be transparent in the program [Image: 16x16char5mi.png] can anone help me
#1. Convert the bitmap to palettized 8-bit BMP, or PUT (PP256)
#2. Load the bitmap into your program
#3. Know how to use PUT

And to make the blue parts transparent, you should make them black rather and use the XOR and AND options in the PUT command to PUT masked.
Or you could write your own PUT routine.

Edit: Sorry no more help, I'm sleepy >_>
so if save img in paint as "256 Color Bitmap (*.bmp,*.dib), and place in same directory as the .bas file, but then how do i load, i read the help thing, but didnt wuite understand
Hi,

you can use a graphic lib for loading/show images.
i.e. AK-LIB

here are the links for the Lib and for the manual:
http://www.iconsoft.de/download/ak15english.zip
http://www.iconsoft.de/manual/ak15en.html

start QB with the option "/L ak15.qlb".
then, if you use SCREEN 13 wrote this:

Code:
CALL XScreen (&H13)
CALL Set.Filter ("ON", 0)       'enter the transparent color instead 0
CALL Set.Picture (0, 0, "yourpic.bmp" )
Code:
DEFINT A-Z
'$DYNAMIC

DECLARE SUB neoImageLoadArrayBMP (Filename AS STRING, Array() AS INTEGER, Pal AS STRING)

SUB neoImageLoadArrayBMP (Filename AS STRING, Array() AS INTEGER, Pal AS STRING)
    'loads a BMP file into an array (PUT-compatible)
    '- Filename: BMP file to load
    '- Array(): array to put it in
    '- Pal: the BMP's palette will be stored in here

    FF = FREEFILE
    OPEN Filename FOR BINARY AS #FF
        'stuff
        p$ = SPACE$(18)
        GET #FF, , p$
        

        'now width and height
        Wid& = 0
        Hei& = 0
        GET #FF, , Wid&
        GET #FF, , Hei&
        REDIM Array((Wid& * Hei& + 4) \ 2) AS INTEGER

        segm% = VARSEG(Array(0))
        offs% = VARPTR(Array(0))

        DEF SEG = segm%

        POKE offs%, (Wid& MOD 32) * 8
        POKE offs% + 1, Wid& \ 32
        POKE offs% + 2, Hei&
        POKE offs% + 3, 0

        offs% = offs% + 4

        'crap
        p$ = SPACE$(28)
        GET #FF, , p$

        'now the palette
        p$ = SPACE$(1024)
        GET #FF, , p$
        Pal = ""
        FOR I = 1 TO 1024 STEP 4
            B% = ASC(MID$(p$, I, 1)) \ 4
            G% = ASC(MID$(p$, I + 1, 1)) \ 4
            R% = ASC(MID$(p$, I + 2, 1)) \ 4
            Pal = Pal + CHR$(R%) + CHR$(G%) + CHR$(B%)
        NEXT I

        'now image data
        DEF SEG = segm%
        FOR zy = Hei& - 1 TO 0 STEP -1
            dat$ = SPACE$(Wid&)
            GET #FF, , dat$
            FOR zx = 0 TO Wid& - 1
                POKE offs% + Wid& * zy + zx, ASC(MID$(dat$, zx + 1, 1))
            NEXT zx
        NEXT zy
    CLOSE #FF
END SUB

This is a BMP loading routine, directly copied from NeoLib v1.6. I tested it on your image and it seemed to work fine.
I cant give any guarantees though.

The BMP will be stored in Array() in PUT format, so you can just use PUT to put it anywhere on screen.

Also you need to set the palette after you loaded the bmp.
..., ya, um, erm, im lost, im so lost in that code, i cant even start using it properly