コード例 #1
0
void RemoveCodedBackground()
{
    LPFRAME lpFrame;
    int x, y;
    int Width;
    int Height;
    LPTR lpSrcLine;
    BYTE r, g, b;
    
    if (!lpImage) return;
    ImgCombineObjects(lpImage, TRUE, FALSE, TRUE);
    lpFrame = ImgGetBaseEditFrame(lpImage);
    if (!lpFrame) return;
    Width  = FrameXSize (lpFrame);
    Height = FrameYSize (lpFrame);

    for (y=0;y<Height;y++)
    {
	    AstralClockCursor( y, Height, NO );
        lpSrcLine = FramePointer (lpFrame,0,y,TRUE);

        for (x=0;x<Width;x++)
        {
            RGBS Pixel;
            FrameGetRGB (lpFrame,lpSrcLine,&Pixel,1);
            r = Pixel.red;
            g = Pixel.green;
            b = Pixel.blue;

            if (r >= 100 && !g && !b)
            { // a dot
                Pixel.red   = 255;
                Pixel.green = 255;
                Pixel.blue  = 255;
                FrameSetRGB (lpFrame,&Pixel,lpSrcLine,1);
            }
			else
            if ( (r != g) || (g != b) )
            { // not white or black
                Pixel.red   = 0;
                Pixel.green = 0;
                Pixel.blue  = 0;
                FrameSetRGB (lpFrame,&Pixel,lpSrcLine,1);
            }
            lpSrcLine += 3;
            
        } // Width
    }     // Height
}
コード例 #2
0
static BOOL NEAR PathIsClear (int x1,int y1,int x2,int y2)
{
    BOOL bClear = TRUE;
    int  i;
    LPFRAME lpFrame = ImgGetBaseEditFrame (lpImage);

    nNumLinePoints = 0;
    ddaline (x1,y1,x2,y2, (LPPOINTFUNC)MazeLineProc);
    for (i = 0; i < nNumLinePoints; i++)
    {
        RGBS Pixel;
        LPTR lpLine = FramePointer (lpFrame,
            MazeLinePoints[i].x,MazeLinePoints[i].y,FALSE);

        FrameGetRGB (lpFrame,lpLine,&Pixel,1);
        if (!Pixel.red && !Pixel.green && !Pixel.blue)
        {
            bClear = FALSE;
            break;
        }
    }
    return bClear;
}
コード例 #3
0
void InitPoints()
{
	int 		i;
	LPFRAME 	lpFrame;
	int 		Width;
	int 		Height;
	int 		x,y;
	LPTR 		lpSrcLine;
	BYTE 		r, g, b;

	iActiveDot = 0;
	iNumDots = 0;

// Clear out the array	
	for (i=0; i<MAX_DOTS; i++)
	{
		DotPoints[i].x = 0;
		DotPoints[i].y = 0;
	}

    if (!lpImage) return;
    lpFrame = ImgGetBaseEditFrame(lpImage);
    if (!lpFrame) return;
    Width  = FrameXSize (lpFrame);
    Height = FrameYSize (lpFrame);

// Find all the points in the image.
// Search for coded dots that indicate a dot-to-dot point.
// These dot points will be drawn as circles for the user to click in.
// An array of points - DotPoints[] is maintained to remember these dots.
    for (y=0;y<Height;y++)
    {
	    AstralClockCursor( y, Height, NO );
        lpSrcLine = FramePointer (lpFrame,0,y,FALSE);

        for (x=0;x<Width;x++)
        {
            RGBS Pixel;
            FrameGetRGB (lpFrame,lpSrcLine,&Pixel,1);
            r = Pixel.red;
            g = Pixel.green;
            b = Pixel.blue;
            if (r >= 100 && g == 0 && b == 0)
            {
            	// This is a coded pixel that contains:
            	//  1) green - No coding.  MUST be 0.
            	//  2) red   - Sequence that the dot is found.
            	//  3) blue  - No coding.  MUST be 0.
				r -= 100;
				if (r >= 0 && r <= MAX_DOTS)
				{
					// Save the Dot position.
					// Do not allow the dot to go off the screen.
					DotPoints[r].x = min(x, Width  - ((DOT_DIAMETER / 2) + 2));
					DotPoints[r].y = min(y, Height - ((DOT_DIAMETER / 2) + 2));
					iNumDots = max(iNumDots, r);
				}
            }
            lpSrcLine += 3;
        } // Width
    }     // Height
}
コード例 #4
0
static BOOL FAR MazeToolProc (HWND hWnd,LONG lParam,WORD wMsg)
{
    HDC     hDC;
    LPFRAME lpFrame;
    LPTR    lpLine;
    POINT   pt;
    RGBS    Pixel;
    static int x1,y1;

    pt.x = LOWORD(lParam);
    pt.y = HIWORD(lParam);
    switch (wMsg)
    {
    case WM_LBUTTONDOWN:
        if (!bTrack)
        {
            lpFrame = ImgGetBaseEditFrame (lpImage);
            lpLine = FramePointer (lpFrame,pt.x,pt.y,FALSE);
            FrameGetRGB (lpFrame,lpLine,&Pixel,1);
            if (Pixel.green && !(Pixel.red & Pixel.blue)) // start green pel
            {
//                SoundStartID (IDC_LINES,NO,0);
                SoundStartResource ("icons",NO,0);
                MazeTrailPoints[0].x = x1 = pt.x;
                MazeTrailPoints[0].y = y1 = pt.y;
                nNumTrailPoints = 1;
                if (bShowSolution || bSolved)
                {
                    bShowSolution = bSolved = FALSE;
                    InvalidateRect (hWnd,NULL,FALSE);
                    UpdateWindow (hWnd);
                }
                bTrack = TRUE;
            }
            else if (!AnimateProc(hWnd,lParam,wMsg))
                SoundStartResource ("WRONGANSWER1",NO,0);
        }
        break;
    case WM_MOUSEMOVE:
        if (!bTrack)
            break;
        if (!fAppActive || GetUpdateRect (hWnd,NULL,FALSE))
        {
            InvertLine (hWnd,x1,y1,x1,y1);
            break;
        }
        InvertLine (hWnd,x1,y1,pt.x,pt.y);
        if (!LBUTTON || (pt.x == x1 && pt.y == y1))
            break;
        // else button is down, so fall through to anchor a point
    case WM_LBUTTONUP:
        if (bTrack)
        {
            if (PathIsClear (x1,y1,pt.x,pt.y))
            {
                lpFrame = ImgGetBaseEditFrame (lpImage);
                lpLine = FramePointer (lpFrame,pt.x,pt.y,FALSE);
                FrameGetRGB (lpFrame,lpLine,&Pixel,1);
                if (Pixel.red && !(Pixel.green & Pixel.blue)) // end red pel
                {
                    SoundStartResource ("GOODANSWER1",NO,0);
					StartAnimation(hWnd);
                    bSolved = TRUE;
                    bTrack = FALSE;
                }
                else
                {
                    hDC = GetDC (hWnd);
                    DrawLineEx (hDC,x1,y1,pt.x,pt.y,
                        hMazePen ? hMazePen : (HPEN)GetStockObject (BLACK_PEN),FALSE);
                    ReleaseDC (hWnd,hDC);
                    x1 = pt.x;
                    y1 = pt.y;
                    if (nNumTrailPoints < MAX_LINEPOINTS)
                    {
                        MazeTrailPoints[nNumTrailPoints].x = x1;
                        MazeTrailPoints[nNumTrailPoints].y = y1;
                        nNumTrailPoints++;
                    }
                }
            }
            else
                SoundStartResource ("WRONGANSWER1",NO,0);
        }
        break;
    case WM_PAINT:
        if (bTrack)
        {
            int i;

            hDC = GetDC (hWnd);
            pt.x = MazeTrailPoints[0].x;
            pt.y = MazeTrailPoints[0].y;
            for (i = 1; i < nNumTrailPoints; i++)
            {
                DrawLineEx (hDC,pt.x,pt.y,
                    MazeTrailPoints[i].x,MazeTrailPoints[i].y,
                    hMazePen ? hMazePen : (HPEN)GetStockObject (BLACK_PEN),FALSE);
                pt.x = MazeTrailPoints[i].x;
                pt.y = MazeTrailPoints[i].y;
            }
            ReleaseDC (hWnd,hDC);
        }
        break;
    }
    return TRUE;
}