如何使用布局尺寸正确裁剪图像blob?

时间:2018-01-08 04:58:35

标签: appcelerator appcelerator-titanium titanium-alloy

使用相机拍摄的图像裁剪的正确方法是什么,以匹配用户在曝光部分屏幕的叠加层中可以查看的内容。

我正在使用与showcamera的叠加来捕捉我的图像。

透明覆盖层顶部有一个标签,屏幕中间有一个视图(顶部:315) - 所以摄像机在标签和视图之间显示。 (见下文)

recv()

然后我使用showCamera裁剪图像,成功:这样的函数()......

<View class="overlay">
    <!-- this view is transparent -->
    <View id="View_title_area">
        <!-- view height 50 / white background -->
        <Label id="Label_title" class="page_title"  text="Take Photo"/>  
    </View> 

    <!-- Camera is displayed here -->
    <!-- Camera is displayed here -->
    <!-- Camera is displayed here -->
    <!-- Camera is displayed here -->

    <View id="View_control_area">
        <!-- view top=315 -->
        <Label id="Label_instruction" text="{image_aspect_instruction}" />              
        <Button id="Button_capture" class="button_white" onClick="Button_capture_onClick"  title=" Take Photo " />
    </View>             
</View>

我意识到基本问题是相机正在捕捉图像@ 2448w x 3264h并且我正在使用dpi布局尺寸裁剪图像。该怎么做?

var device_width = Ti.Platform.displayCaps.platformWidth;

var camera_height =  Math.round((camera_width/4)*3);  

var newblob = e.media.imageAsCropped({x: 0, y:51, width : device_width, height : 215 });

$.imagetest.image = newblob;

0 个答案:

没有答案
相关问题