2

image2がimage2.scaleImage32()メソッドでスケーリングされない理由を誰かが知っていますか?

これが私のコードです:

public ZoomScreen setScreen(){

     map1.getBitmap().scaleInto(tempBmp, Bitmap.FILTER_BILINEAR); 
     Graphics g = Graphics.create(tempBmp); //works
     g.drawBitmap(100, 100, bitmapImage2.getWidth(), bitmapImage2.getHeight(), bitmapImage2, 0, 0); //works
     image2 = PNGEncodedImage.encode(tempBmp); //works
     image3 = image2.scaleImage32(Fixed32.toFP(100), Fixed32.toFP(200)); // does not work
     ZoomScreen screen = new ZoomScreen(image3);// works

  return screen;

}
4

1 に答える 1

0

おそらく、幅と高さの絶対値をscaleImage32()メソッドに渡しています。ただし、この方法を使用する正しい方法ではありません。幅と高さの絶対値ではなく、スケール係数を渡す必要があります。

EncodedImageクラスのインスタンスであり、ピクセル単位でスケーリングされた画像の側面であると仮定するimageと、次のコードが機能するはずです。thumbnailSide

        final int currentWidthFixed32 = Fixed32.toFP(image.getWidth());
        final int currentHeightFixed32 = Fixed32.toFP(image.getHeight());

        final int thumbnailSideFixed32 = Fixed32.toFP(thumbnailSide);

        final int scaleXFixed32 = Fixed32.div(currentWidthFixed32, thumbnailSideFixed32);
        final int scaleYFixed32 = Fixed32.div(currentHeightFixed32, thumbnailSideFixed32);

        image = image.scaleImage32(scaleXFixed32, scaleYFixed32);
于 2012-08-20T09:01:39.293 に答える