Originally Posted by
DaveH
Code:
hOldBmp = SelectObject (hMemDC, hBmp);
Selects the new bitmap and stores the original bmps handle into hOldBmp.
By Original you referring to an empty/blank frame, since there was not image before inserting the earth?
So Dave, after this line, i may not draw anything to the earth image? meaning i would have to select it again, or maybe get its handle again ... I'm learning a lot from this and please don't loose patience with me
According to the documentation, an application should always replace a new object with the original, default object after it has finished drawing with the new object.
Two questions, probably last ones...
1. I would like to draw different lines at different times (i.e At first a horizontal line across the image, after 5 seconds a vertical line across the image... I plan to then loop the following function twice ...
Code:
// Function to draw line on the image
void DrawLine(POINTS coord, POINTS factor)
{
hBmp = Earth.GetHandle();
hOldBmp = SelectObject(hMemDC, hBmp);
MoveToEx(hMemDC, coord.x, coord.y, &myPoint);
LineTo(hMemDC, coord.x+factor.x, coord.y+factor.y);
SelectObject (hMemDC, hOldBmp);
DeleteDC (hMemDC);
}
Q. My only concerns in the code are: If DeleteDC deletes memory DC, calling DrawLine for the second time requires me to first GetHandle of the image, then selectObject, after drawing delete it again (as i have done in the code).. Is this correct (looping the above code)....?
2. After drawing a line in the image, how do i save the new image with the newly drawn line, such that i can continue adding more line...
Thanks a lot Dave