[Solved] GetPixel_

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[Solved] GetPixel_

Post by IdeasVacuum »

Is GetPixel_ still supported?

Code from an old (working) program

Code: Select all

GetCursorPos_(@igPt)
igRGB = GetPixel_(ghDC, igPt\x, igPt\y)
... only returns Black :mrgreen:
Last edited by IdeasVacuum on Mon Aug 29, 2022 12:43 am, edited 1 time in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: GetPixel_

Post by chi »

Still working...

Code: Select all

ghDC = GetDC_(GetDesktopWindow_())

GetCursorPos_(@igPt.POINT)
igRGB = GetPixel_(ghDC, igPt\x, igPt\y)
Debug Hex(igRGB)

ReleaseDC_(GetDesktopWindow_(), ghDC)
Et cetera is my worst enemy
User avatar
tft
User
User
Posts: 99
Joined: Mon Dec 29, 2008 9:34 am

Re: GetPixel_

Post by tft »

When you want to grab a pixel from a video, for example Crunchiroll. this won't work. At least if you have W10 and a computer with DRM protection mechanism. The data is then displayed directly on the screen. Not on the desktop anymore.

Code: Select all

ghDC = GetDC_(GetDesktopWindow_())

GetCursorPos_(@igPt.POINT)
igRGB = GetPixel_(ghDC, igPt\x, igPt\y)

ReleaseDC_(GetDesktopWindow_(), ghDC)
this works fine ....

TFT
TFT seid 1989
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak :-)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: GetPixel_

Post by IdeasVacuum »

Thanks for your help guys

The original code for the desktop handle was:

Code: Select all

ghDC = GetDC_(0)
I changed that to GetDesktopWindow_() , but the result is the same. So I think there is probably a failure earlier in the code - more testing tonight.

Edit: It was indeed a bug elsewhere!
Last edited by IdeasVacuum on Sun Aug 28, 2022 1:21 pm, edited 1 time in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: GetPixel_

Post by BarryG »

tft wrote: Sun Aug 28, 2022 9:29 amWhen you want to grab a pixel from a video, for example Crunchiroll. this won't work.
Using GetDC_(0) works with CrunchyRoll videos for me - the correct pixel color is returned. Both windowed (in-browser) and full-screen playback.

Using Win 10 Pro. Don't know about any DRM settings in Windows.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: GetPixel_

Post by IdeasVacuum »

BarryG wrote: Sun Aug 28, 2022 11:31 am Using GetDC_(0) works with CrunchyRoll videos for me - the correct pixel color is returned. Both windowed (in-browser) and full-screen playback.
Yes, GetDC_(0) covers the entire 'virtual desktop' across however many monitors there are. Works with any pixel grab for me (Now I have fixed the bug that silently messed it up).
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply