Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bitmap loader that doesn't use PALETTE?

Status
Not open for further replies.

sandmann999

Programmer
Apr 28, 2001
52
0
0
US
Hi, I'm trying to find a bitmap loader that doesn't use the palette function.
My reason is this:
I'm making an RPG, and am using Bitmaps (made with a regular paint program) for all the monster pictures, and am doing them in 256 colors so that they can be used with SCREEN 13.
But what I want to is make a secondary program where I can load the bitmap images one at a time, and then BSAVE them to a file so all I have to do is BLOAD them into the game. However, the bitmap loading program I'm using uses the palette feature to make all the colors, so when I BLOAD the picture that I made into my RPG, the palette isn't set, so the picture comes up with all the colors wrong.
Does anyone know a bmp loader that only works in 256 colors (and doesn't use the PALETTE command)? Or is there another way around this? Because if I make 200 monster pictures, and they all require different palettes, they're not going to be compatible on the screen at the same time.
Thanks for any help!
 
I had a similar problem when i was creating my FPS game, I drew up the sprites and saved them as 8bit bitmaps (look great), but The palettes really didn't work for me, like for you.

So what I did was worked around it, I changed The colours within the game so that I could use the palettes that were needed to use the bitmap files.

So draw all of the monsters in one bitmap, then load it, save the images (monster1.pix, monster2.pix...) but also save the palettes as something like palette.scn

You might be a redneck if... you think a megabyte is a good day of fishing.
 
Hrm...that would be really hard to put all of the monsters onto one bitmap. We're talking maybe...150 different monsters? Each 80x60 resolution.

I probably just need to find a way where the colors from the bitmap are the same color number in QBASIC, if that makes sense.
 
Oh, well then you are going to have to load them and figure out the closest colour. Let's see.

You'd have to find the closest one by taking the colour with the least average difference between all three hues (red, green, and blue.) That seems pretty hard, I'll play with it and see if I can't come up with something, I am probably going to need a simialr program down the road anyway.

You might be a redneck if... you think a megabyte is a good day of fishing.
 
Well, for the time being, I went and programmed up a drawing program in QBASIC. Made it so you can select your color (all visible on the screen at one time) and then draw in the drawing box. Made features like circle and line. Can also save your progress, and export (BSAVE) the picture.
Right now it's designed for an 80x50 picture (because that's all I need), but it could be modified. If you want a copy, I can send it to you.
If someone could show me how to use the mouse in QBASIC (QB45, not QB11. All the mouse routines I've seen get an error in QB45), I think this program would work fantastic.
 
DECLARE SUB Mousestatus (lb%,mb%,rb%,xmouse%,ymouse%)
DECLARE SUB Mousehide ()
DECLARE SUB Mousedriver (ax%,bx%,cx%,dx%)
DECLARE SUB Mouseshow ()
DIM SHARED mouse$
Mouse$ = SPACE$(57)
FOR n% = 1 to 57
READ a$
h$ = CHR$(VAL("&H"+a$))
MID$(Mouse$, n%, 1) = h$
NEXT
DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89.0F
DATA 8B,5E,06,89,17,5D,CA,08,00
SCREEN 12
Mousedriver 4,0,320,240
Mouseshow
WHILE x$ = INKEY$
Mousestatus lb%,mb%,rb%,x%,y%
LOCATE 1,1
PRINT lb%,mb%,rb%,x%,y%
x$ = INKEY$
WEND

SUB Mousedriver (ax%,bx%,cx%,dx%)
DEF SEG = VARSEG(Mouse$)
Mouse$ = SADD(Mouse$)
CALL Absolute(ax%,bx%,cx%,dx%,Mouse%)
END SUB

SUB Mousehide
Mousedriver 2,0,0,0
END SUB

SUB Mouseshow
Mousedriver 1,0,0,0
END SUB

SUB Mousestatus (lb%,rb%,xmouse%,ymouse%)
Mousedriver 3,bx%,cx%,dx%
lb% = ((bx% AND 1)<>0)
mb% = ((bx% AND 4)\4)
rb% = ((bx% AND 2)<>0)
xmouse% = cx%
ymouse% = dx%
END SUB

You might be a redneck if... you think a megabyte is a good day of fishing.
 
Tried the mouse program, but I got an error that said &quot;Out of Data&quot; and I have no idea what kind of data needs to be added.
Also, is there any way to use CALL ABSOLUTE without adding a /l on the command line? I always get an error that says &quot;Subprogram not defined&quot; unless I type in QB.EXE /L on the command line.
 
Never mind, I fixed it. There was simply a period where a comma was supposed to be in the data statements.

 
Oh, I didn't even notice that and no, you haev to have the /l command to use CALL ABSOLUTE

You might be a redneck if... you think a megabyte is a good day of fishing.
 
Here's an idea:

Make a bitmap out of screen 13, that way you already have the correct palette, then you can draw your monsters in true colour in another bitmap, and when you copy and paste them, Windows will automatically change the palette around to fit the first bitmap:
If you don't know how to convert SCREEN 13 into a bitmap here is some code:

a& = 1
SCREEN 13
OPEN FileName$ FOR BINARY AS #1
IF LOF(1) <> 0 THEN
CLOSE #1
KILL FileName$
OPEN FileName$ FOR BINARY AS #1
END IF
ValidBMP$ = &quot;BM&quot;: Empty$ = MKL$(0): PictureDataOffset$ = MKL$(1078)
PUT #1, , ValidBMP$
PUT #1, , Empty$
PUT #1, , Empty$
PUT #1, , PictureDataOffset$
WinOrOS2$ = MKL$(40): WidthInPixels$ = MKL$(320)
LengthInPixels$ = MKL$(320): NoOfPlanes$ = MKI$(1)
NoOfBits$ = MKI$(8): NoCompression$ = MKL$(0): AllColors$ = MKL$(0)
IF (4 - (320 MOD 4)) = 4 THEN
SizeOfImageInBytes$ = MKL$((320 * 320))
ELSE
SizeOfImageInBytes$ = MKL$(((320 + (4 - (320 MOD 4))) * 320))
END IF
PUT #1, , WinOrOS2$
PUT #1, , WidthInPixels$
PUT #1, , LengthInPixels$
PUT #1, , NoOfPlanes$
PUT #1, , NoOfBits$
PUT #1, , NoCompression$
PUT #1, , SizeOfImageInBytes$
PUT #1, , Empty$
PUT #1, , Empty$
PUT #1, , AllColors$
PUT #1, , AllColors$
Empty$ = SPACE$(1)
FOR Colors = 0 TO 255
OUT &H3C6, &HFF
OUT &H3C7, Colors
Red$ = CHR$(INP(&H3C9) * 4): Green$ = CHR$(INP(&H3C9) * 4): Blue$ = CHR$(INP(&H3C9) * 4)
PUT #1, , Blue$
PUT #1, , Green$
PUT #1, , Red$
PUT #1, , Empty$
NEXT Colors
SCREEN 13
DIM Image%(1 TO 32767)
GET (0, 0)-(319, 200), Image%
ImageVarSeg = VARSEG(Image%(1))
ImageVarOffset = VARPTR(Image%(1))
DEF SEG = ImageVarSeg
BSAVE &quot;temp.fil&quot;, ImageOffset, 320 * 320
LineOfBytes$ = SPACE$(320): Padding$ = SPACE$(0)
IF (4 - (320 MOD 4)) <> 4 THEN Padding$ = SPACE$((4 - (320 MOD 4)))
Empty$ = SPACE$(11)
OPEN &quot;temp.fil&quot; FOR BINARY AS #2
GET #2, , Empty$
FOR Loops = 320 - 1 TO 0 STEP -1
GET #2, 12 + (320 * Loops), LineOfBytes$
PUT #1, , LineOfBytes$
LINE (0, Loops)-(319, Loops), 0
PUT #1, , Padding$
NEXT Loops
CLOSE #2: KILL &quot;temp.fil&quot;
SizeOfFile$ = MKL$(LOC(1))
PUT #1, 3, SizeOfFile$


You might be a redneck if... you think a megabyte is a good day of fishing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top