120 if (targetRect.width() <= 0 || targetRect.height() <= 0)
128 qreal yPos = targetRect.y();
138 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
139 QVector<float> originalMatrix(9);
140 vgGetMatrix(originalMatrix.data());
142 while (!
qFuzzyCompare(yPos, targetRect.y() + targetRect.height()) &&
143 yPos < targetRect.y() + targetRect.height()) {
145 if (yPos + drawH * scaleY > targetRect.y() + targetRect.height()) {
147 if (!
qFuzzyCompare((
float)(yPos + drawH * scaleY), (
float)(targetRect.y() + targetRect.height())))
148 drawH = targetRect.y() + targetRect.height() - yPos;
150 xPos = targetRect.x();
156 while (!
qFuzzyCompare(xPos, targetRect.x() + targetRect.width()) &&
157 xPos < targetRect.x() + targetRect.width()) {
159 if (xPos + drawW * scaleX > targetRect.x() + targetRect.width()) {
161 if (!
qFuzzyCompare((
float)(xPos + drawW * scaleX), (
float)(targetRect.x() + targetRect.width())))
162 drawW = targetRect.x() + targetRect.width() - xPos;
164 if (round(drawW) > 0 && round(drawH) > 0) {
166 VGImage childRectImage = vgChildImage(
image, xOff, yOff, round(drawW), round(drawH));
167 vgTranslate(xPos, yPos);
168 vgScale(scaleX, scaleY);
169 vgDrawImage(childRectImage);
170 vgDestroyImage(childRectImage);
171 vgLoadMatrix(originalMatrix.constData());
174 xPos += drawW * scaleX;
178 yPos += drawH * scaleY;
188 qMax(innerTargetRect.top() - targetRect.top(),
qreal(0.0)),
189 qMax(targetRect.right() - innerTargetRect.right(),
qreal(0.0)),
190 qMax(targetRect.bottom() - innerTargetRect.bottom(),
qreal(0.0)));
201 QRectF topTargetRect(margins.
left(), 0.0, innerTargetRect.width(), margins.
top());
203 QRectF bottomTargetRect(margins.
left(), targetRect.height() - margins.
bottom(), innerTargetRect.width(), margins.
bottom());
205 QRectF leftTargetRect(0.0, margins.
top(), margins.
left(), innerTargetRect.height());
207 QRectF rightTargetRect(targetRect.width() - margins.
right(), margins.
top(), margins.
right(), innerTargetRect.height());
215 targetRect.topLeft());
224 bottomLeftSourceRect,
225 QPointF(targetRect.left(), targetRect.height() - margins.
bottom()));
229 bottomRightSourceRect,
230 QPointF(targetRect.width() - margins.
right(), targetRect.height() - margins.
bottom()));
232 double scaledWidth = 1.0;
233 double scaledHeight = 1.0;
236 VGImage topImage = vgChildImage(
image, topSourceRect.x(), topSourceRect.y(), topSourceRect.width(), topSourceRect.height());
237 scaledWidth = (topTargetRect.width() / subSourceRect.width()) / topSourceRect.width();
241 vgDestroyImage(topImage);
244 VGImage bottomImage = vgChildImage(
image, bottomSourceRect.x(), bottomSourceRect.y(), bottomSourceRect.width(), bottomSourceRect.height());
245 scaledWidth = (bottomTargetRect.width() / subSourceRect.width()) / bottomSourceRect.width();
249 vgDestroyImage(bottomImage);
252 VGImage leftImage = vgChildImage(
image, leftSourceRect.x(), leftSourceRect.y(), leftSourceRect.width(), leftSourceRect.height());
253 scaledHeight = (leftTargetRect.height() / subSourceRect.height()) / leftSourceRect.height();
256 vgDestroyImage(leftImage);
259 VGImage rightImage = vgChildImage(
image, rightSourceRect.x(), rightSourceRect.y(), rightSourceRect.width(), rightSourceRect.height());
260 scaledHeight = (rightTargetRect.height() / subSourceRect.height()) / rightSourceRect.height();
264 vgDestroyImage(rightImage);
267 VGImage centerImage = vgChildImage(
image, centerSourceRect.x(), centerSourceRect.y(), centerSourceRect.width(), centerSourceRect.height());
269 scaledWidth = (innerTargetRect.width() / subSourceRect.width()) / centerSourceRect.width();
270 scaledHeight = (innerTargetRect.height() / subSourceRect.height()) / centerSourceRect.height();
274 vgDestroyImage(centerImage);