Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Color of screen pixel : Has anyone found a faster way than memblock to do this

Author
Message
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 9th Jul 2016 16:58
Hi there

my own memblock method to get the color of a pixel on screen :



...is way to slow using interactively/live when I need to find a lot of points for each sync...

anyone have a faster solution?

Tim
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jul 2016 17:43
i would remove the render() & clearscreen(), then a fix image and memblock id
GetImage( imageID, x, y, width, height )
CreateImageFromMemblock( imageID, memID )

the return value as integer
MakeColor ( red, green, blue )
later
GetColorBlue ( color )
GetColorGreen ( color )
GetColorRed ( color )
be sure getImage width,height 1,1 is ~ 1 pixel. if u used 100x100 virtual its 1% there and maybe much more as you want.


AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 9th Jul 2016 17:50 Edited at: 9th Jul 2016 17:51
Hi Markus

I'm "painting" over the pixels live - so I need to use render so the changes is computed...
Dont I have to use render then?

Tim
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jul 2016 20:59
i think render() & clearscreen() is at the wrong place inside a readpixel color command.
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 11th Jul 2016 10:55
Hi Markus
I ditched calling getimage and creatememblock for each cycle because it is too slow
And also the render() and clearScreen() as you pointed out.

What Im trying to do is sort of painting with large brushes. And the pixels on the screen should be affected by the the different alpha values in the brush. And the brushes are very many.

Instead I made an Array to reflect the different pixels in my brush. So I only have to make this array when I change my brush. Much faster and it gives me much more possibilities.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jul 2016 16:22
ui
my idea is using a image with full window sprite and SetImageMask for copy your alpha values from an image brush into your sprite image.

AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jul 2016 18:36 Edited at: 11th Jul 2016 18:38
i made a example to play with
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 11th Jul 2016 20:09 Edited at: 12th Jul 2016 03:50
SetImageMask sounds interesting. Have to try that out

This is a video of my prototype - As you can see its not a painting program - the circles are lamps that is affected by the alpha value from the brush


EDIT: Link deleted

I will check out your code
Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jul 2016 20:31
ahh, this video explains it better
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Jul 2016 00:29 Edited at: 12th Jul 2016 00:34
something new, its like a scratchcard, i made a background pic and set all pixels nearly invisible within code and use it at fullwindow sprite.
with mouse down i add alpha from the brush image together with background, my pc can do it in realtime with memblock commands.

an other idea is just to fade in your circles by range. means all circles are sprites and fade it via SetSpriteColor ( iSpriteIndex, iRed, iGreen, iBlue, iAlpha ) , so if your mouse get near u add the alpha, its not pixel perfect but will look similar.

AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 12th Jul 2016 01:18 Edited at: 12th Jul 2016 01:24
Quote: "something new, its like a scratchcard"

Nice. I used my own images.... It was to slow on my laptop. And it crashed after some time.
I really need some effective way....

Thats why....:
@Markus
Quote: "an other idea is just to fade in your circles by range"

THIS IS IT!
Great. It really makes sense. Then the brush will actually behave like a power source. The closer the power source is - the more power the lamps get. The brush is actually just a visual guide anyway. And I can just scale the brush instead of recalculating an array. I dont even need the array
It makes everything so much simpler!! Thank you for that, Markus. You made my day.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Jul 2016 01:32
ok, fine

(i guess this scratchcard memblock example crashed because u painted outside the memblock size.)
AGK (Steam) V2.0.19 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 12th Jul 2016 01:39
Quote: "i guess this scratchcard memblock example crashed because u painted outside the memblock size"

Yes, that was it. It chrashes when the brush hits the border of window.

Login to post a reply

Server time is: 2024-11-25 05:50:03
Your offset time is: 2024-11-25 05:50:03