/*----------------------------------------------------------------------------- * FUNCTION: SCRSVR_PicOnUsrMessage * SCOPE: Screen saver screen related function - local * DESCRIPTION: User message handler function for picture object, to redraw the last picture position by background color * * PARAMETERS: pMsg - pointer to D4D_MESSAGE structure * * RETURNS: return if this message discard or not *-----------------------------------------------------------------------------*/ static Byte SCRSVR_PicOnUsrMessage(D4D_MESSAGE* pMsg) { if(pMsg->nMsgId == D4D_MSG_DRAWDONE) { D4D_SIZE pictSize = D4D_GetBmpSize(((D4D_PICTURE*)scrsvr_picLogo.pParam)->pBmp); D4D_SIZE rectSize; D4D_POINT rectPoint; // Draw the horizontal box rectSize.cy = D4D_Abs16(dy); rectSize.cx = pictSize.cx; rectPoint = oldPos; if(oldPos.y > scrsvr_picLogo.position.y) rectPoint.y += pictSize.cy; D4D_FillRect(&rectPoint, &rectSize, D4D_COLOR_BLACK); // Draw the vertical box rectSize.cx = D4D_Abs16(dx); rectSize.cy = pictSize.cy; rectPoint = oldPos; if(oldPos.x > scrsvr_picLogo.position.x) rectPoint.x += pictSize.cx; D4D_FillRect(&rectPoint, &rectSize, D4D_COLOR_BLACK); } return D4D_MSG_NOSKIP; }
void D4D_LCD_Line (D4D_COOR x1, D4D_COOR y1, D4D_COOR x2, D4D_COOR y2, D4D_LINETYPE line_type, D4D_COLOR color) //draw line - bresenham algorithm { sWord delta_x, delta_y; sByte ix, iy; if((x1 == x2) || (y1 == y2)) // if the line is vertical or horizontal then draw box function is faster than general bresenham algorithm { if(line_type == D4D_LINE_THICK) { if(x1 > x2) { D4D_LCD_SwapCoor(&x1, &x2); } if(y1 > y2) { D4D_LCD_SwapCoor(&y1, &y2); } x2++; y2++; } D4D_LCD_Box(x1 ,y1 ,x2 , y2, color); return; } delta_x = (sWord)(D4D_Abs16((sWord)(x2 - x1)) << 1); delta_y = (sWord)(D4D_Abs16((sWord)(y2 - y1)) << 1); // if x1 == x2 or y1 == y2, then it does not matter what we set here ix = (sByte)((x2 > x1)?1:-1); iy = (sByte)((y2 > y1)?1:-1); D4D_LCD_PutPixel((D4D_COOR) x1, (D4D_COOR) y1, line_type, color); if (delta_x >= delta_y) { // error may go below zero sLWord error = delta_y - (delta_x >> 1); while (x1 != x2) { if (error >= 0) { if (error || (ix > 0)) { y1 += iy; error -= delta_x; } // else do nothing } // else do nothing x1 += ix; error += delta_y; D4D_LCD_PutPixel((D4D_COOR) x1, (D4D_COOR) y1, line_type, color); } }