Separating console colors from image colors in QB64

Separating console colors from image colors in QB64

Joined: February 2nd, 2006, 10:38 pm

February 22nd, 2010, 7:04 pm #1

The following information from Galleon shows how to use _NEWIMAGE(x, y, 32) to separate the consol colors while editing image colors.

Quote from Galleon:
I'm going to take a leap of faith at this point and guess you are working on a 256 color image editor where you need to see the image you are editing but also buttons etc in their appropriate palette. I'll go further and assume that the buttons are also created in a 256 color mode with their own unique palette. The solution is storing (and editing) these as 256 color images but displaying them on a 32-bit screen as they are being edited, like so:

SCREEN _NEWIMAGE(800, 600, 32)
c = _LOADIMAGE("f:\backgroundconsole.bmp", 256)
i = _LOADIMAGE("f:\my256col.bmp", 256)
_PUTIMAGE , c
_PUTIMAGE (10, 10), i

Yes, you can _PUTIMAGE a 256 color image onto a 32-bit image. When the user edits the screen, just use _DEST & _SOURCE to redirect output to image i and update the screen again. END Quote

It only requires you to create a bitmap of the console.


Ted

Quote
Like
Share

Joined: May 31st, 2004, 10:14 am

February 22nd, 2010, 11:25 pm #2

*
Quote
Like
Share

Joined: February 2nd, 2006, 10:38 pm

February 23rd, 2010, 4:24 am #3



Code:

_TITLE "Bitmap Color Editor"
dst& = _NEWIMAGE(800, 600, 32) 'for console bitmap
SCREEN dst&
con& = _LOADIMAGE("BMPConsole.bmp", 256)
_PUTIMAGE, con&
tbl& = _LOADIMAGE("ColorTable.bmp", 256)
_PUTIMAGE (652, 20), tbl&

sleep

bmp& = _LOADIMAGE("howie2.bmp", 256) ' adopts colors with _COPYPALETTE
_PUTIMAGE (6, 6)-(435 + 5, 435 + 5), bmp& 'howie2

'bmp& = _LOADIMAGE("QB64logo.bmp", 256) ' use any 4 0r 8 BPP bitmap
'_PUTIMAGE (6, 6)-(632 + 5, 480 + 5), bmp& ' use second coordinates to stretch the image

'-(502 + 5, 450 + 5), bmp&, dst& 'genie


_COPYPALETTE bmp&, tbl& 'with NEW 32 ' reset color table to bitmap's settings
_PUTIMAGE (652, 20), tbl&

' _DEST con& 'does not help prints

wide& = _WIDTH (bmp&)
deep& = _HEIGHT (bmp&)
COLOR 254: LOCATE 32, 5: PRINT wide&; "X"; deep&

So far I can't figure how to update the console readings. The only print that works is the one above.

Ted
Quote
Like
Share

Joined: May 31st, 2004, 10:14 am

February 23rd, 2010, 5:52 pm #4

*
Quote
Like
Share

Joined: February 2nd, 2006, 10:38 pm

February 23rd, 2010, 6:56 pm #5

I tried compiling my old QB bitmap programs to see how they worked. After I ran my BSAVER program I lost MSPaint for some reason. No icons so I changed them to my PaintShop Pro icon.

I don't know what happened, but I think I'm better off finding the colors used in the bitmap by reading the file data. Otherwise using _COPYPALETTE would take off colors above 15 in 4 bit bitmaps. Your QB64logo makes many colors turn white. I only want colors used to be changed to the bitmap's palette

Once I know what colors are used, I can paint unused attributes to the consol with the same RGB settings. Sort of like floating colors that will be reserved from changes.

So I'm gonna just use 256 mode and none for the bitmap like I originally did. I'll just draw the console and color table like I started to do. The old code still works!

Ted
Quote
Like
Share

Joined: May 31st, 2004, 10:14 am

February 24th, 2010, 3:25 am #6

*
Quote
Like
Share

Joined: February 2nd, 2006, 10:38 pm

February 24th, 2010, 6:42 am #7

I probably need to better understand the 32 bit concept and I doubt Galleon has the time lately.

I already found a way to get a color for the menu in QB so I really don't need the 32 bit exclusive color way. Especially with 256 attributes to work with.

Also I planned to add options and menus to the console as it ran. I can just PUT the options to a console and changes in values are easier to display. PRINT is useless in 32 bit and I have no idea how to change values either.

It's not helping QB64 if it is over the user's head. I hope you can figure it out Bob.

Ted
Last edited by burger2227 on February 24th, 2010, 6:52 am, edited 1 time in total.
Quote
Like
Share

Joined: May 31st, 2004, 10:14 am

February 24th, 2010, 7:20 pm #8

Fortunately, my current projects, and next planned projects, don't require that kind of color sophistication. With my graphics utility I'm only using 35 of the attributes for the interface and I'm happy. Getting to use all 256 (for such things as games), will leave me wondering how to use them all. Anyway, keep me posted if you come up with anything on the 32-bit method.

-Bob
Last edited by qb432l on February 24th, 2010, 7:23 pm, edited 1 time in total.
Quote
Like
Share

Joined: February 2nd, 2006, 10:38 pm

February 25th, 2010, 9:17 pm #9

* I will Bob. It has not been discussed much and Galleon has been busy.
Quote
Like
Share