문제

2x2 또는 3x3 사진의 매트릭스가 있다고 상상해보십시오.이 4 또는 9 장의 사진을 사용하여 하나의 큰 그림을 만들고 싶습니다. 사진 상자 에이 사진을 보여주고 싶습니다.

Windows Mobile 앱을 개발하고 있습니다.

어떻게 할 수 있습니까?

편집 : 설명을 설명하기 위해 질문으로 댓글을 옮겼습니다 ..

일반적으로 당신은 이와 같은 그림 상자에 이미지를 pictureBox.image = myImage. 4 개의 이미지를 사용하여 MyImage를 만들고 싶습니다. 이미지가 있고 4 개의 제곱 조각으로 자른다고 상상해보십시오. 이 4 개의 이미지를 사용하여 원래 이미지를 다시 샘플링하고 싶습니다.

고맙습니다!

도움이 되었습니까?

해결책

이 같은:

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;

다른 팁

4 Och 9 PictureBox를 서로 옆에 배치하거나 PictureBox 대신 패널을 사용하고 Panles Paint 이벤트에서 모든 이미지를 GraphImage를 사용합니다.

이것은 작동하지만 테스트되지 않았습니다.

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top