Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help understanding response of the GfxLib - 2 Problems
#1
While I am on my adventures in arcade game programming I started to play with loading bitmaps. When I load and run the following, the colors of the bitmap change. What gives?

Here is a link to the bitmap.

Or here it is:
[Image: Groovy.bmp]

Notice it should be yellow. This is an 8 bit bitmap because I can not get anything higher to work (I've tried in PaintShop Pro 7 and Paint, in each case either it shows the whole image (no masking) or nothing.

Here is the test code:
Code:
SCREEN 18,8,2,1
DIM image(272*272+4) AS UBYTE

BLOAD "groovy.bmp", @image(0)
color 0,4
cls

dim letter(32*32+4) as ubyte
dim r as integer
dim c as integer
dim x as integer
dim y as integer
dim m as integer
dim oldx as integer
dim oldy as integer
   r=0
   c=0
   get image, (C*32,r*32)-((C+1)*32-1,(R+1)*32-1), letter
do
   screenset 1,0
   getmouse x,y,,m
   if m<>0 then
      select case m
      case 1
         r+=1
      case 2
         c+=1
      case 4
         r=0
         c=0
      end select
      if r>7 then r=0
      if c>7 then c=0
      get image, (C*32,r*32)-((C+1)*32-1,(R+1)*32-1), letter
   end if
        
   if x<>oldx or y<>oldy or m<>0 then
      cls
      put (x,y),letter
      screencopy
      oldx=x
      oldy=y
      ? m
   end if
loop until multikey(&h1)

Changing the background color changes the color of the loaded image.

Now to question 2:

How can I slow down the getmouse routine. Before I can get my finger off of the button it has scrolled through dozens of rows or columns.

1) Why the color change?
1a) Any advice on getting bitmaps to work in 16, 24, or 32 depths (I know about magic pink $HFF00FF)
2) The mouse bit.
Reply
#2
Ok, here are some answers:

1) The problem is you're using PUT with no mode specified. Like in QB, the default PUT operative mode is XOR if you omit it, so you're basically drawing in XOR mode. The color index of your letters is xor'ed with color 4 (the background color you set), and the resulting index color is written in video memory, resulting in white in your palette. To fix the problem, just replace your PUT call with
Code:
put (x,y),letter,TRANS

1a) You cannot load a truecolor BMP while in 8bpp mode (gfxlib would need complex algorithms to generate an optimal palette out of the truecolor image, and that'd bloat the lib, what I don't want to). If you want to load truecolor BMPs, set a color depth > 8 at SCREEN call.

2) There are many ways to do this. The easiest is to put a "SLEEP n" below your select case, where n is an arbitrary number of milliseconds you want to wait (for example, put 100).
ngelo Mottola - EC++
Reply
#3
1) Ok, thanks that is simple enough.

1a) I tried that in 32bit and 16bit depth screens i.e. screen 19, 32,2,1 (using magic pink in 32 and &hF81F in 16 for the trans color). And I saved a bitmap in Paint with a 24bit depth...same thing (Paintshop Pro won't do anything above 8bit bitmaps as far as I can find). I must be doing something wrong.

2) I just did a check to see if the button had changed, if not skip it.


Thanks Mate for the answers.
Reply
#4
Quote:1) (Paintshop Pro won't do anything above 8bit bitmaps as far as I can find)

I use Paintshop Pro for all my graphics with no probleam at all. The command interface in my FreeTrek is a 24-bit bitmap, using SCREEN 18, 32. Not sure what version of Paintshop you are using, I have v.4.0, but you can increase the color depth with Colors -> Increase Color Depth -> 16 million colors.

Quote:How can I slow down the getmouse routine. Before I can get my finger off of the button it has scrolled through dozens of rows or columns.

I had the same problem in Crazy Colors. I added a sleep command to the end of my GetButton routine in order to slow down the mouse clicks. Don't put it in your Do-Loop (or whatever your loop structure is) as it will cause you to miss mouse clicks; at least that was the problem I was having. Putting sleep in GetButton seemed to work very well.
Reply
#5
I have version 7 and when you save as a bitmap it forces a decrease to 256 color.
Reply
#6
Deactivate RLE encoding in the bitmap saving options and you will be able to save 24 bits images.
Antoni
Reply
#7
RLE only exists on palette based images anyway, turning RLE off won't help with 15/16/24/32 bit images.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)