Page 1 of 4
How can I get a pixel color?
Posted: Tue Nov 01, 2022 10:48 am
by vol
Is there a way to get the color of a pixel at a given location in Basic? It seems I have to use some PEEKs for this, right? I hope somebody solved this problem long ago. However I can't still find any trace of this solution.

So I am seeking for some help here. A lot of thanks in advance.
Re: How can I get a pixel color?
Posted: Tue Nov 01, 2022 11:53 am
by tofro
Your best bet is probably DIY Toolkit, series "G" - This has SuperBASIC extensions for fast pixel plot and line drawing, as well as a function PIXEL% to do exactly what you want (
http://www.dilwyn.me.uk/tk/ , under "DIY")
Re: How can I get a pixel color?
Posted: Tue Nov 01, 2022 11:53 am
by RalfR
Re: How can I get a pixel color?
Posted: Tue Nov 01, 2022 12:22 pm
by tofro
While DIY TK's PIXEL% works on "Black Box QLs" in MODE4 and 8, Per's RPIX extensions work on High-colour displays (GD2) MODE 32 and 33 (I think it also works in 8-bit palette mode, but am not 100% sure). The OP didn't say what he needs, so I guess both might be of relevance.
Re: How can I get a pixel color?
Posted: Wed Nov 02, 2022 4:34 pm
by Peter
tofro wrote:(I think it also works in 8-bit palette mode, but am not 100% sure).
Is there an 8 bit palette on any QL style machine? I was just aware of the fixed 8 bit Aurora mode.
Re: How can I get a pixel color?
Posted: Wed Nov 02, 2022 8:53 pm
by Derek_Stewart
Hi,
8 bit colours? Is this 2^8 or 256 colours?
QL Mode 4 is 4 colours, 2^2 or 2 bit
QL Mode 8 is 8 colours, 2^3 or 3 bit
I wish there were 256 colours on a QL without SMSQ/E.
The Q68 can do 512x256 Mode 33
Re: How can I get a pixel color?
Posted: Thu Nov 03, 2022 10:47 am
by BSJR
Peter wrote:tofro wrote:(I think it also works in 8-bit palette mode, but am not 100% sure).
Is there an 8 bit palette on any QL style machine? I was just aware of the fixed 8 bit Aurora mode.
SMSQ/E features a palette of 256 colours which can be referenced with an 8-bit value.
WM_PAPER & WM_INK can set these colours with values $200 to $2FF.
The obscure GD2 sprite modes 3(1-bit), 7(2-bit), 15(4-bit) & 31(8-bit) also use this palette.
The PALETTE_8 command allows changing these colours with new 24-bit RGB values.
Also the standard QL palette of 8 colours can be changed with PALETTE_QL under SMSQ/E.
The 8-bit Aurora mode 16 is a true RGB colour with 3 bits for G and 2 for R & B each, the last bit is a combined R & B bit.
BSJR
Re: How can I get a pixel color?
Posted: Thu Nov 03, 2022 10:56 am
by pjw
BSJR wrote:<>The 8-bit Aurora mode 16 is a true RGB colour with 3 bits for G and 2 for R & B each, the last bit is a combined R & B bit. <>
And both QPC2 and SMSQmulator can be fired up in Aurora-compatible mode 16.
Re: How can I get a pixel color?
Posted: Thu Nov 03, 2022 10:58 am
by BSJR
BSJR wrote:...WM_PAPER & WM_INK can set these colours with values $200 to $2FF...
Oops. This should of course be $100 to $1FF, the $200 range are the 15-bit system palette colours definable by QCoCo.
BSJR
Re: How can I get a pixel color?
Posted: Sat Nov 05, 2022 6:57 am
by vol
Thanks but I wanted not to use any Basic expansion. So I had to find another way. My project is to convert an
Amstrad CPC Basic program to other platforms. The last results are
here.
I have to confess that the QL conversion has so far been the most difficult task because of peculiarities of the FOR-operator implementation in SuperBasic and the absence of a means to get the color of a pixel.