Page 1 of 1
Gray Scale
Posted: Sat Aug 02, 2014 10:21 pm
by chris319
This handy program draws a gray scale for adjusting your monitor.
Code: Select all
InitSprite(): InitKeyboard()
#screenWd = 1365: #screenHt = 768
OpenWindow(0,0,0, #screenWd, #screenHt, #NULL$,#PB_Window_BorderLess)
AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape) ;"ESCAPE" KEY TO QUIT PROGRAM
StartDrawing(WindowOutput(0))
ShowCursor_(#False) ;HIDE MOUSE POINTER
Box(0,0,#SCREENWD,#SCREENHT,$000000)
#STEPS = 12
For ct = 0 To #STEPS - 1
lum.f = (ct / #STEPS) * 255
Box(ct * (#screenWd / #STEPS), 0, #screenWd / #STEPS, #screenHt, RGB(lum,lum,lum))
Next
StopDrawing()
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Repaint
ElseIf event = #PB_Event_Menu ;KEYBOARD INPUT
menuItem = EventMenu()
Select menuItem
Case #PB_Shortcut_Escape
; FreeFont(1): FreeFont(2)
; If ImageID(0) <> 0: FreeImage(0): CloseWindow(0): End: EndIf ;ESCAPE KEY PRESSED
End
EndSelect
EndIf
ForEver
Re: Gray Scale
Posted: Thu Aug 07, 2014 10:22 am
by RichardL
Hi,
A version that works with multiple screens and takes the R,G,B values all the way to 255.
RichardL
Code: Select all
NumDeskTops = ExamineDesktops()
For n = 0 To NumDeskTops-1
ScreenWd = DesktopWidth(n) : Debug "Width "+Str(ScreenWd)
ScreenHt = DesktopHeight(n)
OpenWindow(n,DesktopX(n),0, ScreenWd, ScreenHt, #Null$,#PB_Window_BorderLess)
AddKeyboardShortcut(n, #PB_Shortcut_Escape, #PB_Shortcut_Escape) ;"ESCAPE" KEY TO QUIT PROGRAM
StartDrawing(WindowOutput(n))
Box(0,0,ScreenWd,ScreenHt,$000000)
Steps = 16
X = 0
Lum.f = 0
LumStep.f = 255 / (Steps-1)
XStep = ScreenWd/Steps
For ct = 1 To Steps
Debug Str(X)+" "+Str(Lum)
Box(X,0,XStep,ScreenHt, RGB(Lum,Lum,Lum))
Lum + LumStep
X + XStep
Next
StopDrawing()
Next
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Repaint
ElseIf event = #PB_Event_Menu ;KEYBOARD INPUT
menuItem = EventMenu()
Select menuItem
Case #PB_Shortcut_Escape
Break
EndSelect
EndIf
ForEver
End
Re: Gray Scale
Posted: Thu Aug 07, 2014 11:16 am
by IdeasVacuum
That's good code RichardL - highlighted just how different my monitors are, even though they are the same make and model. Not sure how I'm going to adjust them though........
Re: Gray Scale
Posted: Thu Aug 07, 2014 11:39 am
by luis
IdeasVacuum wrote:Not sure how I'm going to adjust them though........
Windows 7 and higher have a built in calibration software for gamma and .. in some way... color.
http://www.pcmag.com/article2/0,2817,2414252,00.asp
For gamma (the only thing you can really set quite reliably by just using your eyes and the environment light you are normally exposed) I use this software with good results ->
http://quickgamma.de/indexen.html
For color... better buy a cheap hw + sw combination like
http://spyder.datacolor.com/display-calibration/ if possible.
Re: Gray Scale
Posted: Thu Aug 07, 2014 1:37 pm
by chris319
This version continues the white bar all the way to the edge of the screen, and repaints if the window was covered (such as closing the debug window).
Code: Select all
Global screenWd, screenHt
Procedure DrawGrayScale()
StartDrawing(WindowOutput(n))
Box(0,0,ScreenWd,ScreenHt,$ffffff)
Steps = 16
X = 0
Lum.f = 0
LumStep.f = 255 / (Steps-1)
XStep = ScreenWd/Steps
For ct = 1 To Steps
Debug Str(X)+" "+Str(Lum)
Box(X,0,XStep,ScreenHt, RGB(Lum,Lum,Lum))
Lum + LumStep
X + XStep
Next
StopDrawing()
Debug "Press ESC to exit."
EndProcedure
NumDeskTops = ExamineDesktops()
For n = 0 To NumDeskTops-1
ScreenWd = DesktopWidth(n) : Debug "Width "+Str(ScreenWd)
ScreenHt = DesktopHeight(n)
OpenWindow(n,DesktopX(n),0, ScreenWd, ScreenHt, #NULL$,#PB_Window_BorderLess)
AddKeyboardShortcut(n, #PB_Shortcut_Escape, #PB_Shortcut_Escape) ;"ESCAPE" KEY TO QUIT PROGRAM
DrawGrayScale()
Next
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Repaint
DrawGrayScale()
ElseIf event = #PB_Event_Menu ;KEYBOARD INPUT
menuItem = EventMenu()
Select menuItem
Case #PB_Shortcut_Escape
Break
EndSelect
EndIf
ForEver
End
Re: Gray Scale
Posted: Thu Aug 07, 2014 3:38 pm
by RichardL
Hi,
Your procedure DrawGrayScale() needs to have the Window number passed to it...
and then the Repaint will need to provide a Window number (probably all of them!)
Richard
Re: Gray Scale
Posted: Thu Aug 07, 2014 6:28 pm
by chris319
It was intended to occupy the entire display while the user sets his brightness, contrast, etc., not to draw a gray scale in each open window.
Code: Select all
Global screenWd, screenHt
Procedure DrawGrayScale()
StartDrawing(WindowOutput(0))
Box(0,0,ScreenWd,ScreenHt,$ffffff)
Steps = 16
X = 0
Lum.f = 0
LumStep.f = 255 / (Steps-1)
XStep = ScreenWd/Steps
For ct = 1 To Steps
Debug Str(X)+" "+Str(Lum)
Box(X,0,XStep,ScreenHt, RGB(Lum,Lum,Lum))
Lum + LumStep
X + XStep
Next
Debug "Press ESC to exit"
StopDrawing()
EndProcedure
ExamineDesktops()
ScreenWd = DesktopWidth(0) ;: Debug "Width "+Str(ScreenWd)
ScreenHt = DesktopHeight(0)
OpenWindow(0,0,0, ScreenWd,ScreenHt, #NULL$,#PB_Window_BorderLess)
AddKeyboardShortcut(n, #PB_Shortcut_Escape, #PB_Shortcut_Escape) ;"ESCAPE" KEY TO QUIT PROGRAM
DrawGrayScale()
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Repaint
DrawGrayScale()
ElseIf event = #PB_Event_Menu ;KEYBOARD INPUT
menuItem = EventMenu()
Select menuItem
Case #PB_Shortcut_Escape
Break
EndSelect
EndIf
ForEver
End
Re: Gray Scale
Posted: Thu Aug 07, 2014 8:21 pm
by chris319
That's fine with just one combination of computer and monitor, such as a laptop. With one computer and several monitors, IMO you're better off setting the computer's gamma to the standard of 2.2, which can be done with QuickGamma, and dealing with gamma issues in hardware for each individual monitor.
Re: Gray Scale
Posted: Thu Aug 07, 2014 8:40 pm
by luis
Good point, I use it with a single monitor per PC.
With multiple monitors connected to a single PC your approach it's probably better and easier to manage (for you and the software running on it).
Re: Gray Scale
Posted: Thu Aug 07, 2014 11:12 pm
by IdeasVacuum
Darn - Avast really really doesn't like QuickGamma V3 (For XP/Vista). Apparently it is a danger to the entire universe, maybe more.
Edit: QuickGamma is effective, but one of my monitors is determined to keep it's independence.
Re: Gray Scale
Posted: Thu Aug 07, 2014 11:47 pm
by chris319
No problem here running Quick Gamma.
In this thread:
http://www.purebasic.fr/english/viewtop ... 12&t=59993 I posted a toy program which will allow you to adjust the Windows gamma ramp. You can set it to 2.2 (the Windows de-facto standard) and unless your monitor is grossly off, it should be pretty close. I'm not a fan of these programs where you squint at a pattern on the screen and try to match gray levels. At least with my gamma toy or Quick Gamma you can set the gamma to the known value of 2.2 and adjust your monitor hardware while you squint at circles.
One gripe about the Windows gamma adjuster is that it is not calibrated, i.e. you don't know what value you're setting it to. If it becomes misadjusted you have to squint at dots all over again instead of returning it to a known, repeatable value.