万華鏡風対称画像の作成
for (int i = 0; i < 100; i++) { for (int j = 0; j < 100 / 2; j++) { int temp = Pixels1[i*100 + j]; Pixels2[i*100 + j] = Pixels1[i*100 + 100 - 1 - j]; Pixels2[i*100 + 100 - 1 - j] = temp; } }Pixels2[]を元画像の横(下図の2)に描画します。次に、Pixels2[]を上下反転し、これを、右下(下図の3)に表示します。最後に、Pixels1[](元絵)を上下反転しPixels2[]に記録し、これを左下(下図の4)に表示します。
public void MakeMirrorImage(int dispX, int dispY) { // 原画からピクセル情報をPixels1[]に取り込む GetPixels(MirrorImage0, dispX, dispY, 100, 100, Pixels1); MirrorImage1 = createImage(new MemoryImageSource(100, 100, Pixels1, 0, 100)); WorkGraphics1.drawImage(MirrorImage1, 0, 0, this); // 左右対称になるようにデータを入れ替えPixels2[]に記録 for (int i = 0; i < 100; i++) { for (int j = 0; j < 100 / 2; j++) { int temp = Pixels1[i*100 + j]; Pixels2[i*100 + j] = Pixels1[i*100 + 100 - 1 - j]; Pixels2[i*100 + 100 - 1 - j] = temp; } } MirrorImage1 = createImage(new MemoryImageSource(100, 100, Pixels2, 0, 100)); // 作成したイメージをグラフィックスの右上に描画 WorkGraphics1.drawImage(MirrorImage1, 100, 0, this); // 上下対称になるようにPixcel2[]データを入れ替える for (int i = 0; i < 100 / 2; i++) { for (int j = 0; j < 100; j++) { int temp = Pixels2[i*100 + j]; Pixels2[i*100 + j] = Pixels2[(100 - 1 - i)*100 + j]; Pixels2[(100 - 1 - i)*100 + j] = temp; } } MirrorImage1 = createImage(new MemoryImageSource(100, 100, Pixels2, 0, 100)); // 作成したイメージを第1段階の作業グラフィックスの右下に描画 WorkGraphics1.drawImage(MirrorImage1, 100, 100, this); // 上下対称になるようにPixels1[]データをPixels2[]入れ替える for (int i = 0; i < 100/2; i++) { for (int j = 0; j < 100 ; j++) { int temp = Pixels1[i*100 + j]; Pixels2[i*100 + j] = Pixels1[(100 - 1 - i)*100 + j]; Pixels2[(100 - 1 - i)*100 + j] = temp; } } MirrorImage1 = createImage(new MemoryImageSource(100, 100, Pixels2, 0, 100)); // 作成したイメージを第1段階の作業グラフィックスの左下に描画 WorkGraphics1.drawImage(MirrorImage1, 0, 100, this); // WorkImage1のイメージをWorkGraphics2の作業グラフィックスに描画 WorkGraphics2.drawImage(WorkImage1, 0, 0, this); imgDone=true;//表示可能 } }