I-Bild von der Kamera im Querformat nehmen müssen (den gesamten Bildschirm erfassen) mit dieser Maske:Zuschneiderechteck von Bild Ausgabe
Dann Zuschneiderechteck von Bild wie folgt aus:
Ich habe ein Problem beim Zuschneiden. ich tun (android):
public Bitmap getCropImage() {
Bitmap bitmap = getBitmap();
int captureBitmapWidth = bitmap.getWidth();
int captureBitmapHeight = bitmap.getHeight();
// to get a multiplicative factor of axises.
float xCoefficient = captureBitmapWidth/720.0;
float yCoefficient = captureBitmapHeight/480.0;
int cropRectangleWidth = 200;
int cropRectangleHeight = 100;
int cropRectangle_a_x = 200;
int cropRectangle_a_y = 300;
bitmap = Bitmap.createBitmap(bitmap,
Math.round(cropRectangle_a_x * xCoefficient),
Math.round(cropRectangle_a_y * yCoefficient),
Math.round(cropRectangleWidth * xCoefficient),
Math.round(cropRectangleHeight * yCoefficient));
return bitmap;
}
iphone:
extension UIImage {
func crop() -> UIImage {
// to get a multiplicative factor of axises.
let xCoefficient : CGFloat = self.size.width/RectangleConfig.WIDTH;
let yCoefficient : CGFloat = self.size.height/RectangleConfig.HEIGTH;
var cropRect = CGRectMake(RectangleConfig.x * xCoefficient,
RectangleConfig.y * yCoefficient,
RectangleConfig.cropRectWidth * xCoefficient,
RectangleConfig.cropRectHeight * yCoefficient)
cropRect.origin.x *= self.scale
cropRect.origin.y *= self.scale
cropRect.size.width *= self.scale
cropRect.size.height *= self.scale
let imageRef = CGImageCreateWithImageInRect(self.CGImage, cropRect)
let image = UIImage(CGImage: imageRef!, scale: self.scale, orientation: self.imageOrientation)
return image
}
}
Auf einigen mobilen Geräten, bekomme ich das richtige Ergebnis, auf anderen das Zuschneiderechteck nach unten verschoben und nach links. Wo ist der Fehler?