12 #include <QImageReader>
27 QPixmap *entire =
new QPixmap;
29 if (QPixmapCache::find(QString(filename), entire)) {
32 entire->load(QString(filename));
33 QPixmapCache::insert(QString(filename), *entire);
59 QPixmap *
crop_sprite(
const QPixmap *source,
int x,
int y,
int width,
60 int height,
const QPixmap *mask,
int mask_offset_x,
70 if (!width || !height) {
73 cropped =
new QPixmap(width, height);
74 cropped->fill(Qt::transparent);
75 source_rect = QRectF(x, y, width, height);
76 dest_rect = QRectF(0, 0, width, height);
79 p.setRenderHint(QPainter::Antialiasing);
80 p.drawPixmap(dest_rect, *source, source_rect);
84 int mw = mask->width();
85 int mh = mask->height();
87 source_rect = QRectF(0, 0, mw, mh);
88 dest_rect = QRectF(mask_offset_x - x, mask_offset_y - y, mw, mh);
90 p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
91 p.setRenderHint(QPainter::Antialiasing);
92 p.setRenderHint(QPainter::SmoothPixmapTransform);
93 p.drawPixmap(dest_rect, *mask, source_rect);
#define fc_assert_ret_val(condition, val)
QPixmap * crop_sprite(const QPixmap *source, int x, int y, int width, int height, const QPixmap *mask, int mask_offset_x, int mask_offset_y)
Create a new sprite by cropping and taking only the given portion of the image.
QPixmap * load_gfxfile(const char *filename)
Load the given graphics file into a sprite.