Author Topic: help with tinyptc . . .  (Read 3732 times)

0 Members and 2 Guests are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
help with tinyptc . . .
« on: September 17, 2008 »
Hello,
I need a little help please? Not sure if this has been covered before . . .

In tinyptc, how can you check if a pixel is a certain colour? is there a way to read each pixel on the screen and return as a value . . . ?

Regards and appreciation

Andy aka DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: help with tinyptc . . .
« Reply #1 on: September 17, 2008 »
Have a look at the example files of TinyPTC Ext.
There's a buffer (of 32bit integers) which stores the rgb-color (8bit per component) of each pixel:
Code: [Select]
dim shared buffer(640*480) as integer
If you want to display anything, you just have to write it into the buffer.
The whole buffer is then copied to the screen:
Code: [Select]
ptc_update @buffer(0)
So it's really simple to find out the color of a pixel at position x,y:
Code: [Select]
col= buffer(y*640+x)
red= (col shr 16) and 255
green= (col shr 8) and 255
blue= col and 255
(assuming your resolution is 640 * something)
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: help with tinyptc . . .
« Reply #2 on: September 18, 2008 »
@Hellfire
Thanks! I knew it could be done - just couldn't figure out how!
Very much appreciated!

Andy
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: help with tinyptc . . .
« Reply #3 on: September 18, 2008 »
Still having problems . . .

Sub DrawStars1
    for a=0 to ns-1
        testpixel=buffer(y(a)*640+x(a))
        red= (testpixel shr 16) and 255
        green= (testpixel shr 8) and 255
        blue= testpixel and 255
        total = red+green+blue
        'if total=white then dont print! any other colour print?
        if total>0 then pp(x(a),y(a),rgb(r,g,b))
        if total>0 then pp(x1(a),y1(a),rgb(r1,g1,b1))
        if total>0 then pp(x2(a),y2(a),rgb(r2,g2,b2))
        if total>0 then pp(x3(a),y3(a),rgb(r3,g3,b3))
    next a
End Sub

am i doing something really obviously wrong?

Andy
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: help with tinyptc . . .
« Reply #4 on: September 18, 2008 »
"white" means that every color-component is set to maximum (255), so "total" would be 255*3.
Of course you don't have to test every component separately:
Code: [Select]
if testpixel<>&hffffff
  pp(x(a),y(a),rgb(r,g,b))
« Last Edit: September 18, 2008 by hellfire »
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: help with tinyptc . . .
« Reply #5 on: September 18, 2008 »
Btw, if you use the [ code ] and [ / code ] tags, it'll do away with mr smiley.
« Last Edit: September 19, 2008 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: help with tinyptc . . .
« Reply #6 on: September 19, 2008 »
Hellfire,
Thanks for your help on this. It is now working! Cheers

Clyde,
Thanks to you too . . . i always forget about the [ code ] tags!!!
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk