如何在Android和iPhone上拍摄整个屏幕的图像? [英] How can images taking up the whole screen be taken on Android and iPhone?

查看:157
本文介绍了如何在Android和iPhone上拍摄整个屏幕的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可以在整个屏幕上移动的照片,这是在Snapchat应用程序中完成的. Android和iPhone拍摄的图像仅覆盖屏幕中央的一部分(可能是为了使菜单栏可以覆盖其余部分).

I am looking to take photos on mobile that can cover the whole screen, which is done in the Snapchat app. Images taken by Android and iPhone only cover a part in the center of the screen (probably intented so that that menu bars could cover the rest).

如果您戴着手套拍摄图像-并将其导出到相机胶卷,则会看到图像保持放大状态-覆盖了整个屏幕.这就是我希望拍摄照片的方式. (现在,由于图像太小,它们会变形-当我尝试在整个屏幕上显示它们时)

If you take an image in snapchat - and export it to your camera roll, you will see the image remains enlarged - covering the whole screen. That is how I would like my photos being taken. (Right now they become deformed as the images are too small - as I try to display them using the whole screen)

我正在使用Gluon和PicturesService:

I am using Gluon and the PicturesService: http://docs.gluonhq.com/charm/javadoc/4.1.0-SNAPSHOT/index.html?com/gluonhq/charm/down/plugins/PicturesService.html

但是,我认为您需要调整更深层次的内容才能实现这一目标.有人可以指出我正确的方向吗?

However I assume you need to adjust things in deeper layers to acheive this. Could someone point me in the right direction?

推荐答案

iOS上的相机​​纵横比和屏幕纵横比不同.因此,您无法完全显示图像,同时又要避免变形.但是,在视频中,它与屏幕纵横比匹配.因此,我认为Snapchat会以某种方式拍摄屏幕快照,或者在视频模式下从相机中拍摄一帧.

The camera aspect ratio and the screen aspect ratio on iOS differ. That is why you cannot display the image fully and at the same time avoid deformation. However in video it matches the screen aspect ratio. So I thought Snapchat somehow took screenshots, or one single frame out of the camera in video mode.

但是,看着我的Android手机-视频模式下的相机未在整个屏幕上显示(没有匹配的宽高比).我很惊讶.我在上面下载了手套,发现快照仍然覆盖了整个屏幕-令我惊讶的是.

However, looking at my Android phone - the camera on video mode did not display on the whole screen (no matching aspect ratio). I was suprised. I downloaded snapchat on it and found the snaps still covered the whole screen - and I was even more suprised.

然后我开始意识到卡扣在侧面被割断了.因此,他们要做的就是简单地剪切原始图像,直到其与显示器的纵横比匹配为止.

Then I started realizing the snap was cut, at the sides. So what they do is to simply cut the original image until it matches the aspect ratio of the display.

以下内容对我来说可以剪切Android图像:

The following worked for me to cut Android images:

public Image cutImageFit(Scene scene, Image image){
    PixelReader pixelReader = image.getPixelReader();
    double sceneRatio = scene.getWidth() / scene.getHeight();

    double width = image.getWidth();
    double height = image.getHeight();
    double ratio = width / height;

    // System.out.println("Scene is " + scene.getWidth() + " and " + scene.getHeight());
    // System.out.println("sceneRatio " + sceneRatio);
    // System.out.println("ratio is " + ratio);

    if(sceneRatio > 1){
        double cutTo = width / sceneRatio;
        height = cutTo;
    }
    else if(sceneRatio < 1){
        double cutTo = height * sceneRatio;
        width = cutTo;
    }
    else{
        // Square scene...
    }

    Double d = width;
    int w = d.intValue();
    d = height;
    int h = d.intValue();
    System.out.println("new width " + w + " and height " + h + " for the image");
    WritableImage writableImage = new WritableImage(pixelReader, 0, 0, w, h);
    return writableImage;
}

...您还可以编辑该方法,以使其不仅在一侧而且在两侧都被切割.这很有帮助: JavaFX中的有效图像裁剪

... You can could also edit the method so that it cuts both sides, instead of only one. This was helpful: Effective image cropping in JavaFX

但是,当涉及到iOS图像时,我遇到了问题.图像必须旋转.如果是垂直使用iphone拍摄的.如果有人可以帮忙,我会很高兴!

我可以通过使用imageView旋转图像,然后使用javafx快照而不是iOS原始图像将javafx快照作为image参数作为pas来解决.这样,本地坐标系在旋转后也将与系统中的其余GUI坐标系保持同步".因此,实际上,完成了x和y轴的重新标记.

This latter problem I could solve by rotating the image with the imageView and then taking a javafx snapshot, to pas as image parameter with the method instead of the iOS original image. That way the local cordinate system also stays "in sync" with the rest of the GUI cordinalts in ate system after rotating. So in effect a relabeling of the x and y - axises is done.

编辑:android defualt相机实际上包含一个我不知道的全屏"设置.因此只需选择该设置.它导致出现白色区域,但是我认为这是因为该应用程序无法显示在状态栏区域上.在其他默认的照片查看器应用程序中,一切看起来都很好(在状态栏下方显示图像).因此,可以使用上面的此方法裁剪图像-或可以使用José在问题注释中建议的独立Android图层创建FullscreenService以显示拍摄的图像.

Edit: The android defualt camera actually contained a "Fullscreen" setting of which I was not aware of. So that setting simply have to be selected. It results in a white area however of which I think comes from that the app cannot display onto the statusbar area. Everything looks fine in the other default photo viewer apps are able to do (displaying image beneath status bar). So either the image can be cropped, using this method above - or a FullscreenService can be create to display the taken image, using a independant seperate Android layer, suggested by José in the comments to the question.

在iOS上,可以使用相机第三方应用程序执行此操作-或编辑IOSPicturesService已连接本机ObjectiveC代码的IOSPicturesService.

When it comes to iOS it might be possible to use camera third party apps, that does this - or edit the IOSPicturesService of which have native ObjectiveC code connected to it.

这篇关于如何在Android和iPhone上拍摄整个屏幕的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆