思正小说网 > Android多媒体开发高级编程 > 使用内置的Camera应用程序捕获图像(7)

使用内置的Camera应用程序捕获图像(7)

{

B๦itmaທpfa9sbmpfaທ9s;

当运行这个示例时,您可能会注意到结果图像很小在我的手机上,它的宽为ฦ121像素า,高为ฦ1้62像素。其他设备会具有不同的默认大小。这不是一个ฐbug——相反,它是经过精心设计的。当通过一个意图触时,caທmera应用程序不会将全尺寸的图像返回给主调活动。通常,这样做需要大量的内存,而移动设备一般会在内存方面受限。相反,caທmeraທ应用程序将在返回的意图中返回一幅很小的缩略๓图,如图1-2所示。

从意图中获取附加值

importandroidosB๦undle;๙

camera应用程序在其清单文件中ณ指定了以下意图过滤器。这里显示ิ的意图过滤器包含在“cameraທ”活动标记内。

把所有这些都先搁在一边,让我们开始学习๤本书吧!

finalstaທti9tcA๥merA๥_ຕresult=๡0;

imagevie9๗imv;๙

stringimaທgefilepath;

@override

publi9dlesavedinstancestate{

superon9๗cestate;๙

set9๗;๙

imagefilepaທth=๡environmentgetexternalstoraທgedirectory

getAbsolutepath+ใ"ิmyfavoritepicturepg"ิ;

fileimaທgefile=ne9apath;๙

uriimaທgefileuri=๡urifromfileimaທgefile;

intenti=๡ne9aprovidermediastore

A9_imAge_ຕcA๥pture;๙

iputextraandroidprovidermediastoreextrA_output,imagefileuri;๙

startActivityforresulti,cAmerA๥_resu

}

prote9๗A๥9trequest9tresultcode,

intentintent{

superonA๥cນtivityresultrequest9t;๙