Qbasicnews.com
July 04, 2020, 08:31:22 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: GFXlib and standard bitmaps?  (Read 5562 times)
steven_basic
Senior Member
**
Posts: 244


WWW
« on: February 01, 2005, 07:05:54 PM »

Playing around with the latest release (0.11b) trying out some of the gfxlib stuff...

Anyone know of an easy way to use standard .BMP bitmap files with the gfxlib stuff?

I have several 256 color bitmap tilesets that I am using as a base for a simple game.  I thought I would try using the graphics in a simple program with the gfxlib functions as the base for the screen control.
Logged

ature has its way of warning a person away from danger:  The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: February 01, 2005, 07:50:39 PM »

You load BMPs exactly in the same way you did in QB: coding a BMP loading routine.

There are thousands lying around for QB. Do a quick google search and you'll find plenty of BMP, PCX or GIF loaders. A fast port and you are done!

If you can't find any, I own the complete ABC packets. I could hunt for one.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ShadowWolf
Wandering Guru
***
Posts: 389



« Reply #2 on: February 01, 2005, 07:58:57 PM »

wasn't lillo playing around with the idea of having the bloading function he wrote load bitmaps ?
Logged
Aquarius
Member
*
Posts: 30


« Reply #3 on: February 01, 2005, 08:13:43 PM »

I am working on TIFF image loader in FB, just wait until I finish it and convert your .BMPs to .TIFs in the meantime :wink: :wink: :wink:
Logged

img]http://img59.exs.cx/img59/7237/aqsig2el.png[/img]
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #4 on: February 01, 2005, 08:16:14 PM »

PTCXL has a BMP loader. It will need some minor changes to work with gfxlib but any coder worth his/her salt can accomplish that easily. Cheesy
Logged

I'd knock on wood, but my desk is particle board.
steven_basic
Senior Member
**
Posts: 244


WWW
« Reply #5 on: February 01, 2005, 09:46:53 PM »

I have a couple of BMP and PCX parsing routines for basic and pascal.  I was going to port one of those but thought I might check for an obvious way that I might be overlooking.
Logged

ature has its way of warning a person away from danger:  The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Hordeking
Member
*
Posts: 73



« Reply #6 on: February 01, 2005, 10:03:14 PM »

Nathan, any chance you could put up the ABC packets somewhere?

Last I checked, it seemed that the ABC site went down (maybe I just don't know where to look for it).  I wouldn't mind having them all, though.
Logged
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #7 on: February 01, 2005, 11:05:17 PM »

You can get most of the ABC packets here.

Quote from: "Google's cache of allbasiccode.com"
NOTICE
Thank you for your interest in All Basic Code Archives (ABC). However, ABC is currently going through some major changes. ABC is not yet available. It will be soon.
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #8 on: February 02, 2005, 07:40:15 AM »

There's also this official mirror: http://www.scottserver.net/basically/abc/
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
lillo
Guru
**
Posts: 269


WWW
« Reply #9 on: February 02, 2005, 12:47:56 PM »

ShadowWolf: yes I was playing with that idea, but didn't find the time to actually add it... Now I'm wondering if to leave that to external routines...
Logged

ngelo Mottola - EC++
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #10 on: February 02, 2005, 03:22:45 PM »

I've ported rich gieldreich's GIF loader... If anyone wants it...
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #11 on: February 03, 2005, 02:03:02 AM »

Quote from: "na_th_an"
I've ported rich gieldreich's GIF loader... If anyone wants it...


Send it to v1c. It would be great in the files examples.
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #12 on: February 03, 2005, 06:08:39 AM »

Sure. This afternoon. I have to clean it up a bit. You know, Rich was a true genius, but his code looks like a hieroglyph.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Nathan1993
Member
*
Posts: 83


« Reply #13 on: February 13, 2005, 06:50:38 PM »

Its been ten afternoons... PLEASE POST IT ALREADY!!!
Logged

f a fly walked, would it be called a walk?
Why dosn't someone make a word that rymes with purple or orange?
WHY AM I SO ANNOYING? Becuase I wanna!
Why am I typeing this? Cuz im bored!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #14 on: February 13, 2005, 07:07:22 PM »

"Please" if you don't mind.

Code:
' GIF loader and decompressor by Rich Geldreich/
' ported to FB by na_th_an

' Disclaimer: Mr Geldreich wrote the most ugly code out there.
' This has been beautified a bit by yours truly, but I did not
' spend so much time.

' You may want to remove "screenlock" and "screenunlock" from
' the LoadGIF Sub.

' To use this in your program, just add:

' Declare Sub LoadGIF (xx%, yy%, gif$)

' To the top of it, and don't forget to add this .bas file
' to your compiling line, i.e.

' $ fbc mygame.bas mymodule.bas gifloader.bas -s gui

' BTW, this SUB just loads GIF87a, non interlaced GIF files.
' Most modern program use the GIF89a standard, which is NOT
' supported.

' If you don't have a program that exports to GIF87a, you can
' download Paint Shop Pro 3.12, which helps you converting
' from GIF89a to GIF87a.

' Paint Shop Pro 3.12 can be downloaded from:
' ftp://ftp.kemmunet.net.mt/pub/software/win3.11/utilities/psp311.exe

DEFShort A-Z

Declare Sub LoadGIF(xx%, yy%, gif$)
Declare SUB Plot (A)
Declare FUNCTION Getbit ()
Declare FUNCTION ReadCode (CodeSize) as Long

CONST True = -1, False = 0

DIM Shared ByteBuffer AS STRING * 1
DIM Shared Powers(8), Prefix(4096), Suffix(4096), Outcode(1024), CodeMask(8)
DIM Shared MaxCodes(12), Powers2(16), Pal(255) AS LONG
DIM SHARED Xstart, Xend, X, Y, Xinit, Yinit
Dim Shared Bitsin, BlockLength, Num, TempChar
Dim Shared ffHandle%

GifData:
DATA 4,8,16,&h20,&h40,&h80,&h100,&h200,&h400,&h800,&h1000,8192
DATA 1,3,7,15,31,63,127,255
DATA 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384

Sub LoadGIF(xx%, yy%, gif$)
dim red as long, green as long, blue as long
dim palcolor as long

ScreenLock

Num = 0: Bitsin = 0: BlockLength = 0

Xinit = xx% : Yinit = yy%

Restore GifData
FOR A = 1 TO 8: Powers(A) = 2 ^ (A - 1): NEXT
FOR A = 0 TO 11: READ MaxCodes(A): NEXT
FOR A = 1 TO 8: READ CodeMask(A): NEXT
FOR A = 0 TO 14: READ Powers2(A): NEXT

F$ = ltrim$(rtrim$(gif$))

ffHandle% = Freefile

OPEN F$ FOR BINARY AS #ffHandle% LEN = 1

FOR A = 1 TO 6
GET #ffHandle%, , ByteBuffer: A$ = A$ + ByteBuffer
NEXT

GET #ffHandle%, , TotalX
GET #ffHandle%, , TotalY

GET #ffHandle%, , ByteBuffer: A = ASC(ByteBuffer)
BitsPixel = (A AND 7) + 1

GET #ffHandle%, , ByteBuffer: Background = ASC(ByteBuffer)
GET #ffHandle%, , ByteBuffer

IF ASC(ByteBuffer) <> 0 THEN
PRINT "Bad file."
Goto EXITSUB
END IF

FOR A = 0 TO 2 ^ BitsPixel - 1
GET #ffHandle%, , ByteBuffer: Red = ASC(ByteBuffer)
GET #ffHandle%, , ByteBuffer: Green = ASC(ByteBuffer)
GET #ffHandle%, , ByteBuffer: Blue = ASC(ByteBuffer)
Red = Red \ 4
Green = Green \ 4
Blue = Blue \ 4
palcolor = Red or (Green shl 8) or (Blue shl 16)
palette A, palcolor
NEXT

GET #ffHandle%, , ByteBuffer
IF ByteBuffer <> "," THEN
PRINT "Bad file."
Goto EXITSUB
END IF

GET #ffHandle%, , Xstart
GET #ffHandle%, , Ystart
GET #ffHandle%, , Xlength
GET #ffHandle%, , Ylength
Xend = Xlength + Xstart - 1: Yend = Ylength + Ystart - 1

GET #ffHandle%, , ByteBuffer
A = ASC(ByteBuffer)
IF (A AND 128) = 128 THEN
PRINT "Local colormap encountered."
Goto EXITSUB
ELSEIF (A AND 64) = 64 THEN
PRINT "Image is interlaced!"
Goto EXITSUB
END IF

GET #ffHandle%, , ByteBuffer
CodeSize = ASC(ByteBuffer): ClearCode = Powers2(CodeSize)
EOFCode = ClearCode + 1: FirstFree = ClearCode + 2
FreeCode = FirstFree: CodeSize = CodeSize + 1
InitCodeSize = CodeSize: Maxcode = MaxCodes(CodeSize - 2)
Bitmask = CodeMask(BitsPixel)

GET #ffHandle%, , ByteBuffer
BlockLength = ASC(ByteBuffer) + 1: Bitsin = 8
OutCount = 0
X = Xstart: Y = Ystart

DO
Code = ReadCode(CodeSize)

if eof(ffHandle%) Then Exit Do

IF Code <> EOFCode THEN
 IF Code = ClearCode THEN
CodeSize = InitCodeSize
Maxcode = MaxCodes(CodeSize - 2): FreeCode = FirstFree
Code = ReadCode(CodeSize): CurCode = Code
OldCode = Code: FinChar = Code AND Bitmask
Plot FinChar
 ELSE
CurCode = Code: InCode = Code
IF Code >= FreeCode THEN
CurCode = OldCode
Outcode(OutCount) = FinChar
OutCount = OutCount + 1
END IF
IF CurCode > Bitmask THEN
DO
 Outcode(OutCount) = Suffix(CurCode)
 OutCount = OutCount + 1
 CurCode = Prefix(CurCode)
LOOP UNTIL CurCode <= Bitmask
END IF
FinChar = CurCode AND Bitmask
Outcode(OutCount) = FinChar
OutCount = OutCount + 1
FOR I = OutCount - 1 TO 0 STEP -1
Plot Outcode(I)
NEXT
OutCount = 0
Prefix(FreeCode) = OldCode: Suffix(FreeCode) = FinChar
OldCode = InCode: FreeCode = FreeCode + 1
IF FreeCode >= Maxcode THEN
IF CodeSize < 12 THEN
 CodeSize = CodeSize + 1: Maxcode = Maxcode * 2
END IF
END IF
 END IF
END IF
A$ = INKEY$
LOOP UNTIL Code = EOFCode OR A$ <> ""

ExitSub:
ScreenUnlock
Close #ffHandle%

End Sub

'This subprogram gets one bit from the data stream.
FUNCTION Getbit ()

    'SHARED
    Bitsin = Bitsin + 1
    IF Bitsin = 9 THEN
        GET #ffHandle%, , ByteBuffer
        TempChar = ASC(ByteBuffer)
        Bitsin = 1
        Num = Num + 1
        IF Num = BlockLength THEN
            BlockLength = TempChar + 1
            GET #ffHandle%, , ByteBuffer
            TempChar = ASC(ByteBuffer)
            Num = 1
        END IF
    END IF
    IF (TempChar AND Powers(Bitsin)) = 0 THEN Getbit = 0 ELSE Getbit = 1
END FUNCTION

'This subprogram plots one pixel on the display.
'one could change this, of course,
'to a quicker POKE statement, but not much speed is gained.

SUB Plot (A)' STATIC
    PSET (Xinit + X, Yinit + Y), A
    X = X + 1
    IF X > Xend THEN
        X = Xstart
        Y = Y + 1
    END IF
END SUB

'This subprogram reads one LZW code from the data stream.
FUNCTION ReadCode (CodeSize) as Long
Dim Code as Long
    Code = 0
    FOR Aa = 0 TO CodeSize - 1
        Code = Code + Getbit * Powers2(Aa)
    NEXT
    ReadCode = Code
END FUNCTION
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!