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

📄 image.c

📁 QT 做的俄罗斯方快 基于LINUX下的
💻 C
字号:
/*画图函数的代码*/#include "image.h"/*位图填充*/void fill_image(PixImage * image, Color32 color, int x, int y, int w, int h){    if (w == 0)        w = image->width - x;    if (h == 0)        h = image->height- y;    if (x + w > image->width)        w = image->width - x;    if (y + h > image->height)        h = image->height - y;    if (image->pixelbytes == 2) {        Color16 * buf = (Color16 *)(image->buf + image->rowbytes*y + x*image->pixelbytes);        for (y = 0; y < h; y++) {            for (x = 0; x < w; x++)                buf[x] = (Color16)color;            buf += image->width;        }    }    else if (image->pixelbytes == 4) {        Color32 * buf = (Color32 *)(image->buf + image->rowbytes*y + x*image->pixelbytes);        for (y = 0; y < h; y++) {            for (x = 0; x < w; x++)                buf[x] = color;            buf += image->width;        }    }}static void image_copy16(PixImage * dst_image, int dx, int dy, PixImage * src_image, int sx, int sy, int w, int h){    int x, y;    Color16 * src_buf = (Color16 *)(src_image->buf + src_image->rowbytes * sy + sx * src_image->pixelbytes);    Color16 * dst_buf = (Color16 *)(dst_image->buf + dst_image->rowbytes * dy + dx * dst_image->pixelbytes);    for (y = 0; y < h; y++) {        for (x = 0; x < w; x++) {            dst_buf[x] = src_buf[x];        }        dst_buf += dst_image->width;        src_buf += src_image->width;    }}static void image_copy32(PixImage * dst_image, int dx, int dy, PixImage * src_image, int sx, int sy, int w, int h){    int x, y;    Color32 * src_buf = (Color32 *)(src_image->buf + src_image->rowbytes * sy + sx * src_image->pixelbytes);    Color32 * dst_buf = (Color32 *)(dst_image->buf + dst_image->rowbytes * dy + dx * dst_image->pixelbytes);    for (y = 0; y < h; y++) {        for (x = 0; x < w; x++) {            dst_buf[x] = src_buf[x];        }        dst_buf += dst_image->width;        src_buf += src_image->width;    }}/*位图拷贝*/void image_copy(PixImage * dst_image, int dx, int dy, PixImage * src_image, int sx, int sy, int w, int h){    if (w == 0)        w = src_image->width;    if (h == 0)        h = src_image->height;    if (sx >= dst_image->width)        return;    if (sy >= dst_image->height)        return;    if (sx + w > src_image->width)        w = src_image->width - sx;    if (w > dst_image->width - dx)        w = dst_image->width - dx;    if (sy + h > src_image->height)        h = src_image->height - sy;    if (h > dst_image->height - dy)        h = dst_image->height - dy;    if (src_image->pixelbytes == 2)        image_copy16(dst_image, dx, dy, src_image, sx, sy, w, h);    else if (dst_image->pixelbytes == 4)        image_copy32(dst_image, dx, dy, src_image, sx, sy, w, h);}

⌨️ 快捷键说明

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