2

2x2 または 3x3 の画像のマトリックスがあり、これらの 4 枚または 9 枚の画像を使用して 1 つの大きな画像を作成したいとします。この画像をpictureBoxに表示したい。

Windows Mobile アプリを開発しています。

これどうやってするの?

編集:明確にするためにコメントを質問に移動しました..

通常、このように画像を pictureBox にアッシングしますpictureBox.image = myImage。4 つの画像を使用して myImage を構築したいと考えています。画像があり、それを 4 つの正方形に切り取るとします。これらの 4 つの画像を使用して、元の画像を再組み立てしたいと考えています。

ありがとうございました!

4

3 に答える 3

5

このようなもの:

Bitmap bitmap = new Bitmap(totalWidthOfAllImages, totalHeightOfAllImages);
using(Graphics g = Graphics.FromBitmap(bitmap))
{
    foreach(Bitmap b in myBitmaps)
        g.DrawImage(/* do positioning stuff based on image position */)
}

pictureBox1.Image = bitmap;
于 2009-02-24T17:46:36.527 に答える
0

これは動作するはずですが、テストされていません:

private Image BuildBitmap(Image[,] parts) {
    // assumes all images are of equal size, assumes arrays are 0-based
    int xCount = parts.GetUpperBound(0) + 1;
    int yCount = parts.GetUpperBound(0) + 1;

    if (xCount <= 0 || yCount <= 0)
        return null; // no images to join

    int width = parts[0,0].Width;
    int height = parts[0,0].Height;

    Bitmap newPicture = new Bitmap(width * xCount, height * yCount);
    using (Graphics g = Graphics.FromImage(newPicture)) {
        for (int x = 0; x < xCount; x++)
            for (int y = 0; y < yCount; y++)
                g.DrawImage(parts[x, y], x * width, y & height); 
    }

    return newPicture;
}
于 2009-02-24T17:50:18.563 に答える
0

4 つまたは 9 つの PictureBoxes を隣り合わせに配置するか、PictureBox の代わりに Panel を使用し、Graphics.DrawImage を使用して Panles Paint イベントですべての画像を描画します。

于 2009-02-24T17:34:47.307 に答える