The MASM Forum

General => The Campus => Topic started by: Gunther on March 14, 2013, 05:21:30 AM

Title: Pixel manipulation
Post by: Gunther on March 14, 2013, 05:21:30 AM
Is there any example inside the forum pool for manipulating (set and read) pixels, drawing lines, circles etc? Any help is welcome.

Gunther
Title: Re: Pixel manipulation
Post by: jj2007 on March 14, 2013, 06:04:00 AM
You need a DC, i.e. what BeginPaint returns in eax, and various simple graphics functions:
SetPixel
Chord
Ellipse
FillRect
FrameRect
InvertRect
Pie
Polygon
PolyPolygon
Rectangle
RoundRect

Select a brush and a pen into the DC, and go ahead.

Circles are done with
invoke Ellipse, myDC, Rect.left, Rect.top,, Rect.right, Rect.bottom

No rocket science, just try it in the WM_PAINT handler.
hth, jj
Title: Re: Pixel manipulation
Post by: dedndave on March 14, 2013, 06:10:46 AM
you can use SetPixel and GetPixel for maybe a few pixels
but, they are slow
it would seem they create a DC and blit for each pixel
so - much better to create a DC and blit once, edit your pixels, then blit back to the window DC

for lines, there is MoveTo, LineTo, et al

http://msdn.microsoft.com/en-us/library/windows/desktop/dd145031%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/dd145031%28v=vs.85%29.aspx)

the real "work horses" are

CreateCompatibleDC
CreateCompatibleBitmap
CreateDIBSection
BitBlt
StretchBlt
TransparentBlt

and the functions that go with them

DeleteDC
DeleteObject
SetStretchBltMode/SetBrushOrgEx
Title: Re: Pixel manipulation
Post by: Gunther on March 14, 2013, 06:37:03 AM
Hi Dave,

thank you for the hints.  :t

Gunther
Title: Re: Pixel manipulation
Post by: dedndave on March 14, 2013, 06:52:48 AM
there are a number of forum members that i have learned a lot from
of course, there are the usual suspects   :P
and also Seikmanski, guga, gwapo, Tedd, and a few others

another great resource is Jose Roca's site
http://www.jose.it-berater.org/smfforum/index.php (http://www.jose.it-berater.org/smfforum/index.php)

you can search almost any GDI function, and get a few nice examples
Title: Re: Pixel manipulation
Post by: Gunther on March 14, 2013, 08:04:05 AM
Hi Dave,

Quote from: dedndave on March 14, 2013, 06:52:48 AM
there are a number of forum members that i have learned a lot from
of course, there are the usual suspects   :P

oh yes, the usual suspects.

Quote from: dedndave on March 14, 2013, 06:52:48 AM
another great resource is Jose Roca's site
http://www.jose.it-berater.org/smfforum/index.php (http://www.jose.it-berater.org/smfforum/index.php)

you can search almost any GDI function, and get a few nice examples

thank you, great ressource.

Gunther
Title: Re: Pixel manipulation
Post by: dedndave on March 14, 2013, 08:29:54 AM
by "usual suspects", i am refering to the guys we learn all kinds of stuff from
Hutch--, qWord, donkey, Vortex, KetilO, jj2007, MichaelW, FORTRANS, ToutEnMasm, BillCravener, etc

you can use the advanced search tool in the new and the old forums to help find things   :P
Title: Re: Pixel manipulation
Post by: Gunther on March 15, 2013, 08:08:16 AM
Hi Dave,

Quote from: dedndave on March 14, 2013, 08:29:54 AM
by "usual suspects", i am refering to the guys we learn all kinds of stuff from
Hutch--, qWord, donkey, Vortex, KetilO, jj2007, MichaelW, FORTRANS, ToutEnMasm, BillCravener, etc

yes, that was my impression, too.

Quote from: dedndave on March 14, 2013, 08:29:54 AM
you can use the advanced search tool in the new and the old forums to help find things   :P

I'll use the tool.  :t

Gunther
Title: Re: Pixel manipulation
Post by: dedndave on March 15, 2013, 10:27:08 AM
let us know if you have some specific task in mind   :t
Title: Re: Pixel manipulation
Post by: Gunther on March 15, 2013, 06:48:15 PM
Hi Dave,

Quote from: dedndave on March 15, 2013, 10:27:08 AM
let us know if you have some specific task in mind   :t

yes, I'll drop a line.

Gunther
Title: Re: Pixel manipulation
Post by: TouEnMasm on March 16, 2013, 01:39:24 AM

manipulating (set and read) pixels:
There is a fast and a slow method.The slow use API,the fast modify the pixels directly in memory.
A sample of this is here http://masm32.com/board/index.php?topic=835.msg7335#msg7335 (http://masm32.com/board/index.php?topic=835.msg7335#msg7335)
,the region.cpp modifie the pixels to made a transparent color.

Title: Re: Pixel manipulation
Post by: Gunther on March 16, 2013, 01:52:13 AM
Hi ToutEnMasm,

thank you for the link. It was a great help.  :t

Gunther