Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

SET PIXEL COLOR


  • Please log in to reply
4 replies to this topic
richardb
  • Members
  • 4 posts
  • Last active: Mar 02 2006 08:31 PM
  • Joined: 30 Dec 2005
I have looked through forum and help file and think that the only way to set/change a pixel color is via a DLL call (as shown in forum thread). I think this is beyond my capabilities and was hoping there was another way.
Does anyone know of one or is Dll the only way?
Thanks

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
Try this:
SelectCanvas* p_title = name of AHk GUI windowSetPixel* p_x, p_y = coordinates relative to client area (e.g., 0, 0 references the origin)
* p_size = size of pixel
* p_color = 0xRRGGBB or color name[/list]Enjoy!

Gui, Show, w280 h280, gui1: unique title

SelectCanvas( "gui1: unique title" )

SetPixel( 5, 5, 100, "blue" )
SetPixel( 95, 95, 50, "green" )
SetPixel( 135, 135, 100, "red" )
SetPixel( 225, 225, 50, 0xFFFFFF )
return

GuiClose:
ExitApp

SelectCanvas( p_title=false )
{
	static	hw_canvas

	if ( !p_title )
		return, hw_canvas
	
	Process, Exist
	WinGet, hw_canvas, ID, %p_title% ahk_class AutoHotkeyGUI ahk_pid %ErrorLevel%
}

SetPixel( p_x, p_y, p_size, p_color )
{
	static	total
	
	total++

	Gui, Add, Progress, % "x" ( p_x-1 ) " y" ( p_y-1 ) " w" ( p_size+2 ) " h" ( p_size+2 ) " background" p_color
	
	hw_canvas := SelectCanvas()

	; WS_EX_STATICEDGE	
	Control, ExStyle, -0x20000, msctls_progress32%total%, ahk_id %hw_canvas% 
	
	WinSet, Redraw,, ahk_id %hw_canvas%
}


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Super! Do you know a way to draw a line or a circle?

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005

Super! Do you know a way to draw a line or a circle?


Fun, isn't it.

You can draw a line or circle, etc., using SetPixel (i.e., control variant), GDI SetPixel, or other GDI routines.

What do you have in mind?

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

What do you have in mind?

A couple of functions, which draw straight or curved lines (like Bezier curves; circles or more general second order curves; or general parametric planar curves, such as (sin(t),cos(t))). If I programmed them in AHK, via a dll call for each single pixel, large complex drawings would be very slow.