Lee Privett wrote:
I think I asked this question earlier this year but after dropping
my laptop
and losing everything of the hard drive I have lost the emails, can
anyone
tell me if there is a way of detecting the colour of a single pixel
on the
QL screen?
The Spectrum had PLOT x,y ( I think) for switching on a pixel and
the
function POINT x,y for returning a value
Obviously the QL has POINT which plots, so PEEK?
No inbuilt function, although various have been written, e.g. there is
one in DIY Toolkit somewhere.
Depends also on whether you want it to work on full screen coordinates
or window coordinates.
POINT works in graphical units which are SCALE and aspect ratio
dependent. I would have expected that you'd want to work in pixel
units, more like the BLOCK coordinates.
In 8-bit and 16 bit colour modes, it is fairly easy to PEEK the byte
(8-bit mode) or PEEK_W the word (16-bit colour) to get the native
colour value (this assumes full screen pixel coordinates):
DEF FN Pixel8(x,y)
REM for 256 colour mode
RET PEEK(SCR_BASE+(y*SCR_LLEN)+x)
END DEF Pixel8
DEF FN Pixel16(x,y)
REM for 16-bit colour
RET PEEK(SCR_BASE+(y*SCR_LLEN)+(2*x))
END DEF Pixel16
Those functions are not tested, but they should show the principle
even if they are not 100% correct.
This might not mean much to you perhaps, but the colour values
returned in this way would be different for Q60 and QPC2 for example
(can't remember from memory how QXL screen is organise din 16-bit
colour) because the colour is organised differently on both systems.
I suppose you could use Miguel or Simon's routines for mode 4 and
routines like the above for higher colour modes, using the DISP_TYPE
extension in SMSQ/E to select which function is needed for the mode
number in question.
Results would probably vary depending on whether you were writing
colours in QL palette, native colour or even 24-bit colour depth
values. What I'm implying is that colour values returned on various
systems might differ for the same colour value written to the screen.
OK, I'll stop there as I'm confusing myself now.
Dilwyn Jones
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm