News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SetPixel problem.

Started by Hjortur, November 14, 2006, 12:51:48 AM

Previous topic - Next topic

Hjortur

Hello everyone, i am having a little problem with SetPixel().  I just wanted to implement my own circle drawing algorithm.
I dont think that anything is wrong with the algorithm it self it is just that SetPixel fails all the time (return value -1).
Is it that i am trying to draw directly to the screen or does it not matter?
Do I obtain hDC wrongly or does it get destroyed somewhere on the way ?
Is it anything your keen eyes spot but my don't ?  I have been trying to spot what is wrong for hours.  One thing I discovered was that SetPixel trashes my registers that is why there are pushes and pops all over the place.   :bg

I tryed to keep the sorce code clean.  So i made few macros and also Iczelions rgb macro.
swcrd macro simply swithces between x and y cordinates in bx cx.

Source is attached.   Thanks in advance.

ps.  I am not a native English speaker

New working algorithm attached  below !!

[attachment deleted by admin]

Hjortur

ok, I found the problem.
Turns out I was using GetDC instead of GetWindowDC.
Looks like I need to work on my algorithm.
:bg


Hjortur

Well looks like I have got my algorithm running, and now it draws a perfect circle.   :cheekygreen:
If anyone is interested in this algorithm it is attached.
This one has no multiplications just ADD and it keeps every value in the registers so it is memory efficient, and proparbly fast because there are no MUL or IMUL.
If this is somewhat cryptic algorithm it is based around that   x^2  == (x-1)^2 * 2x -1
So if any, enjoy!
:bg

[attachment deleted by admin]