1

ハイ。画像を水平方向に反転したいのですが、次のコードを使用します。

public static EncodedImage flip (Bitmap png)
{
    int width = png.getWidth();
    int height = png.getHeight();
    Bitmap temp = new Bitmap(width,height);
    int[] argb = new int[ width * height ];
    int[] invertArgb = new int[ width * height ];
    png.getARGB( argb, 0, width, 0, 0, width, height );

    for ( int i = height - 1; i >= 0; --i ) {
        for ( int j = width - 1; j >= 0; --j ) {
            invertArgb[ ( width - j - 1 ) + ( width * i ) ] = argb[ j + ( width * i ) ];
        }
    }
    temp.setARGB( invertArgb, 0, width, 0, 0, width, height );

    PNGEncoder encoder = new PNGEncoder(temp, true);
    byte[] imageBytes = null;
    try {
        imageBytes = encoder.encode(true);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    EncodedImage fullImage = EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);

    return fullImage;

}

EncodedImageしかし..少し時間がかかるので、変換せずに直接反転する方法を誰かが考えていますか

PS PNGEncoder.java はこちら: http://www.mobiyana.com/code/blackberry/PNGEncoder.java

4

2 に答える 2

1

有効な解決策は、2 つのバージョンのイメージを提供することです。1 つはノーマルで、もう 1 つは反転しています。もちろん、ロードにかかる時間と、画像に必要なスペースの量を考慮する必要があります。読み込み時間を短縮したい場合は、少なくとも考慮すべき設計上の決定です。

于 2011-05-10T12:56:22.193 に答える
0

Graphics.drawTexturedPath() はあなたのためにできると思います。RIMのこのjavadocを見てください。

于 2011-05-10T07:46:10.927 に答える