How can I get a pixel color?

Anything QL Software or Programming Related.
vol
ROM Dongle
Posts: 22
Joined: Thu Jan 20, 2022 5:07 pm

How can I get a pixel color?

Post 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. :cry: So I am seeking for some help here. A lot of thanks in advance.


User avatar
tofro
Font of All Knowledge
Posts: 3115
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: How can I get a pixel color?

Post 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")


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
RalfR
QL Wafer Drive
Posts: 1191
Joined: Fri Jun 15, 2018 8:58 pm

Re: How can I get a pixel color?

Post by RalfR »



7000 4E75
User avatar
tofro
Font of All Knowledge
Posts: 3115
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: How can I get a pixel color?

Post 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.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Peter
Font of All Knowledge
Posts: 2443
Joined: Sat Jan 22, 2011 8:47 am

Re: How can I get a pixel color?

Post 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.


Derek_Stewart
Font of All Knowledge
Posts: 4738
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: How can I get a pixel color?

Post 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


Regards,

Derek
User avatar
BSJR
Trump Card
Posts: 222
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: How can I get a pixel color?

Post 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


User avatar
pjw
QL Wafer Drive
Posts: 1623
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: How can I get a pixel color?

Post 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.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
BSJR
Trump Card
Posts: 222
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: How can I get a pixel color?

Post 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


vol
ROM Dongle
Posts: 22
Joined: Thu Jan 20, 2022 5:07 pm

Re: How can I get a pixel color?

Post 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.


Post Reply