0
votes

If i have a 1px thick image How would i go about duplicating it so it becomes bigger, or how would i stretch it.

Because as you can see with my code its not the best looping DrawImage

    colorMatrixEffect->SetInput(0, texture); //texture = ID2D1Bitmap*
    D2D1_MATRIX_5X4_F matrix = D2D1::Matrix5x4F(color->r, 0, 0, 0, 0, color->g, 0, 0, 0, 0, color->b, 0, 0, 0, 0, 1, 0, 0, 0, 0);
    colorMatrixEffect->SetValue(D2D1_COLORMATRIX_PROP_COLOR_MATRIX, matrix);

    if (rect.right == 0)
    {
        device_context_d2d1->DrawImage(colorMatrixEffect.get(),
            D2D1::Point2F(newRect.left + offsetX, newRect.top + offsetY));
    }
    else
    {
        for (int i = 0; i < static_cast<int>(newRect.right); i++)
        {
            device_context_d2d1->DrawImage(colorMatrixEffect.get(),
                D2D1::Point2F(newRect.left + offsetX + i, newRect.top + offsetY));
        }
    }
1

1 Answers

0
votes

To stretch the image you can use scaling transformation.

You can also render your image to D2D1Bitmap and draw it as a bitmap, there's DrawBitmap method with more parameters which allows you to draw any part of the bitmap to any part of the target device with stretching.

To draw repeated patterns you can create bitmap or image brush with CreateBitmapBrush/CreateImageBrush method and set extendMode* properties to D2D1_EXTEND_MODE_WRAP value and then just fill desired shape with this brush.