⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abl_swim_image.c

📁 sharp触摸屏测试代码
💻 C
📖 第 1 页 / 共 2 页
字号:
 * Notes:
 *     Pixels should be organized in the image from left to right, top
 *     to bottom. (BMP images are not stored like this.)
 *
 **********************************************************************/
void swim_put_scale_image (SWIM_WINDOW_T *win,
                           const COLOR_T *image,
                           INT_32 xsize,
                           INT_32 ysize)
{
    INT_32 xsc, ysc;
    INT_32 x, y;
    COLOR_T *fb;

    /* Top of window */
    y = win->ypvmin;

    /* Rescale image into window */
    while (y <= win->ypvmax)
    {
        x = win->xpvmin;

        /* Scale he display size to the image size */
        ysc = ((ysize - 1) * (y - win->ypvmin)) / win->yvsize;
        fb = win->fb + x + (y * win->xpsize);

        /* Render a single line */
        while (x <= win->xpvmax)
        {
            /* Get x pixel in image */
            xsc = ((xsize - 1) * (x - win->xpvmin)) / win->xvsize;
            *fb = image [xsc + ysc * xsize];
            fb++;
            x++;
        }
      
        y++;
    }
}

/***********************************************************************
 *
 * Function: swim_put_scale_invert_image
 *
 * Purpose: Puts an raw image in a window scaled and inverted.
 *
 * Processing:
 *     See function.
 *
 * Parameters: 
 *     win   : Window identifier
 *     image : pointer to image data, must be in display color format
 *     xsize : Size of the image in horizontal pixels
 *     ysize : Size of the image in vertical pixels
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes:
 *     Pixels should be organized in the image from left to right, top
 *     to bottom. (BMP images are not stored like this.)
 *
 **********************************************************************/
void swim_put_scale_invert_image (SWIM_WINDOW_T *win,
                                  const COLOR_T *image,
                                  INT_32 xsize,
                                  INT_32 ysize)
{
    INT_32 xsc, ysc;
    INT_32 x, y;
    COLOR_T *fb;

    /* Top of window */
    y = win->ypvmin;

    /* Rescale image into window */
    while (y <= win->ypvmax)
    {
        x = win->xpvmin;

        /* Scale he display size to the image size */
        ysc = ((ysize - 1) * (y - win->ypvmin)) / win->yvsize;
        fb = win->fb + x + (y * win->xpsize);

        /* Render a single line */
        while (x <= win->xpvmax)
        {
            /* Get x pixel in image */
            xsc = ((xsize - 1) * (x - win->xpvmin)) / win->xvsize;
            *fb = image [(xsize - 1 - xsc) + (ysize - 1 - ysc) * xsize];
            fb++;
            x++;
        }
      
        y++;
    }
}

/***********************************************************************
 *
 * Function: swim_put_scale_left_image
 *
 * Purpose: Puts an raw image in a window scaled and rotated left.
 *
 * Processing:
 *     See function.
 *
 * Parameters: 
 *     win   : Window identifier
 *     image : pointer to image data, must be in display color format
 *     xsize : Size of the image in horizontal pixels
 *     ysize : Size of the image in vertical pixels
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes:
 *     Pixels should be organized in the image from left to right, top
 *     to bottom. (BMP images are not stored like this.)
 *
 **********************************************************************/
void swim_put_scale_left_image (SWIM_WINDOW_T *win,
                                const COLOR_T *image,
                                INT_32 xsize,
                                INT_32 ysize)
{
    INT_32 xsc, ysc;
    INT_32 x, y;
    COLOR_T *fb;

    /* Top of window */
    y = win->ypvmin;

    /* Rescale image into window */
    while (y <= win->ypvmax)
    {
        x = win->xpvmin;

        /* Scale y coords of picture into x axis */
        ysc = ((xsize - 1) * (win->ypvmax - y)) / win->yvsize;
        fb = win->fb + x + (y * win->xpsize);

        /* Render a single horizontal line with 'y' data */
        while (x <= win->xpvmax)
        {
            /* Get x pixel in image */
            xsc = ((ysize - 1) * (x - win->xpvmin)) / win->xvsize;
            *fb = image [ysc + xsc * xsize];
            fb++;
            x++;
        }
      
        y++;
    }
}

/***********************************************************************
 *
 * Function: swim_put_scale_right_image
 *
 * Purpose: Puts an raw image in a window scaled and rotated right.
 *
 * Processing:
 *     See function.
 *
 * Parameters: 
 *     win   : Window identifier
 *     image : pointer to image data, must be in display color format
 *     xsize : Size of the image in horizontal pixels
 *     ysize : Size of the image in vertical pixels
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes:
 *     Pixels should be organized in the image from left to right, top
 *     to bottom. (BMP images are not stored like this.)
 *
 **********************************************************************/
void swim_put_scale_right_image (SWIM_WINDOW_T *win,
                                 const COLOR_T *image,
                                 INT_32 xsize,
                                 INT_32 ysize)
{
    INT_32 xsc, ysc;
    INT_32 x, y;
    COLOR_T *fb;

    /* Top of window */
    y = win->ypvmin;

    /* Rescale image into window */
    while (y <= win->ypvmax)
    {
        x = win->xpvmin;

        /* Scale y coords of picture into x axis */
        ysc = ((xsize - 1) * (y - win->ypvmin)) / win->yvsize;
        fb = win->fb + x + (y * win->xpsize);

        /* Render a single horizontal line with 'y' data */
        while (x <= win->xpvmax)
        {
            /* Get x pixel in image */
            xsc = ((ysize - 1) * (win->xpvmax - x)) / win->xvsize;
            *fb = image [ysc + xsc * xsize];
            fb++;
            x++;
        }
      
        y++;
    }
}

/***********************************************************************
 *
 * Function: swim_put_win_image
 *
 * Purpose: This function simply provides a single API for all the
 *          image functions.
 *
 * Processing:
 *     See function.
 *
 * Parameters: 
 *     win   : Window identifier
 *     image : pointer to image data, must be in display color format
 *     xsize : Size of the image in horizontal pixels
 *     ysize : Size of the image in vertical pixels
 *     scale : If set, the picture will be scaled to the window size
 *             If not set, the picture will be clipped
 *     rtype : Rotation type flag, either Norotation, Left, Right, or
 *             Invert
 *
 * Outputs: None
 *
 * Returns: Nothing
 *
 * Notes: None
 *
 **********************************************************************/
void swim_put_win_image (SWIM_WINDOW_T *win,
                         const COLOR_T *image,
                         INT_32 xsize,
                         INT_32 ysize,
                         INT_32 scale,
                         SWIM_ROTATION_T rtype)
{
    switch (rtype)
    {
        case INVERT:
            if (scale != 0)
            {
                swim_put_scale_invert_image (win, image, xsize, ysize);
            }
            else
            {
                swim_put_invert_image (win, image, xsize, ysize);
            }
            break;

        case LEFT:
            if (scale != 0)
            {
                swim_put_scale_left_image (win, image, xsize, ysize);
            }
            else
            {
                swim_put_left_image (win, image, xsize, ysize);
            }
            break;

        case RIGHT:
            if (scale != 0)
            {
                swim_put_scale_right_image (win, image, xsize, ysize);
            }
            else
            {
                swim_put_right_image (win, image, xsize, ysize);
            }
            break;

        case NOROTATION:
        default:
            if (scale != 0)
            {
                swim_put_scale_image (win, image, xsize, ysize);
            }
            else
            {
                swim_put_image (win, image, xsize, ysize);
            }
            break;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -