android中的接触式图像分辨率
我已经检索了android手机联系人图像,并将其存储在arraylist中,如下所示android中的接触式图像分辨率,android,image,resolution,android-contacts,Android,Image,Resolution,Android Contacts,我已经检索了android手机联系人图像,并将其存储在arraylist中,如下所示 id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); String photoWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " +ContactsContract.Data.MIMETYPE + " = ?"; String[] photoParams
id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
String photoWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " +ContactsContract.Data.MIMETYPE + " = ?";
String[] photoParams = new String[] {id,ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE};
Cursor photoCursor = contentResolver.query(ContactsContract.Data.CONTENT_URI, null, photoWhere, photoParams, null);
if(photoCursor!=null && photoCursor.getCount()>0)
{
while(photoCursor.moveToNext())
{
byte[] contactPhoto = photoCursor.getBlob(photoCursor.getColumnIndex(ContactsContract.CommonDataKinds.Photo.PHOTO));
if(contactPhoto!=null)
{
mContactImage="data:image/jpeg;base64," + Base64.encodeToString(contactPhoto, Base64.NO_WRAP);
sContactImageArray.add(mContactImage);
}
}
}
photoCursor.close();
然后我将这个base64字符串传递到javascript中并显示为图像。但是图像分辨率很差。这与手机通讯录中存储的图像不同。如何检索100%质量的联系人图像?请参考这些字段。如果联系人头像是从本地照片设置的,那么您可能有机会获得高分辨率版本
/**
* Reference to the row in the data table holding the photo. A photo can
* be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
* and {@link #PHOTO_URI}).
* If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
* which is a more generic mechanism for referencing the contact photo, especially for
* contacts returned by non-local directories (see {@link Directory}).
*
* <P>Type: INTEGER REFERENCES data(_id)</P>
*/
public static final String PHOTO_ID = "photo_id";
/**
* Photo file ID of the full-size photo. If present, this will be used to populate
* {@link #PHOTO_URI}. The ID can also be used with
* {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
* If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
*
* <P>Type: INTEGER</P>
*/
public static final String PHOTO_FILE_ID = "photo_file_id";
/**
* A URI that can be used to retrieve the contact's full-size photo.
* If PHOTO_FILE_ID is not null, this will be populated with a URI based off
* {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will
* be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
* A photo can be referred to either by a URI (this field) or by ID
* (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
* PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
* vice versa). Thus using PHOTO_URI is a more robust method of retrieving
* contact photos.
*
* <P>Type: TEXT</P>
*/
public static final String PHOTO_URI = "photo_uri";
/**
* A URI that can be used to retrieve a thumbnail of the contact's photo.
* A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
* or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
* PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
* If the content provider does not differentiate between full-size photos
* and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
* the same value, but either both shall be null or both not null.
*
* <P>Type: TEXT</P>
*/
public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
/**
*引用数据表中保存照片的行。照片罐
*可以通过ID(此字段)或URI(请参见{@link#PHOTO_缩略图_URI})引用
*和{@link#PHOTO_URI})。
*如果PHOTO#u ID为空,请查阅{@link#PHOTO#u URI}或{@link#PHOTO#u URI},
*哪一种是引用联系人照片的更通用的机制,尤其是对于
*由非本地目录返回的联系人(请参阅{@link Directory})。
*
*类型:整数引用数据(\u id)
*/
公共静态最终字符串PHOTO\u ID=“PHOTO\u ID”;
/**
*全尺寸照片的照片文件ID。如果存在,这将用于填充
*{@link#PHOTO_URI}。该ID也可用于
*{@link contacts contract.DisplayPhoto#CONTENT_URI}创建照片的URI。
*如果存在这种情况,{@link#PHOTO_ID}也保证被填充。
*
*类型:整数
*/
公共静态最终字符串PHOTO\u FILE\u ID=“PHOTO\u FILE\u ID”;
/**
*一个URI,可用于检索联系人的全尺寸照片。
*如果PHOTO_FILE_ID不为null,则将使用基于
*{@link contacts contract.DisplayPhoto#CONTENT_URI}。否则,这将
*使用与{@link#PHOTO_缩略图_URI}相同的值填充。
*照片可以通过URI(此字段)或ID引用
*(见{@link#PHOTO_ID})。如果照片文件ID或照片ID不为空,
*照片URI和照片URI不得为空(但不一定为空
*反之亦然)。因此,使用PHOTO_URI是一种更健壮的检索方法
*联系照片。
*
*
类型:文本
*/
公共静态最终字符串PHOTO\u URI=“PHOTO\u URI”;
/**
*可用于检索联系人照片缩略图的URI。
*照片可以通过URI(此字段或{@link#photo_URI})引用
*或按ID(见{@link#PHOTO_ID})。如果PHOTO_ID不为null,则PHOTO_URI和
*照片缩略图URI不应为空(但不一定为空)。
*如果内容提供商不区分全尺寸照片
*缩略图照片、照片缩略图URI和{@link#照片URI}可以包含
*相同的值,但两者都应为null或都不为null。
*
*
类型:文本
*/
公共静态最终字符串PHOTO\u thumboil\u URI=“PHOTO\u thumb\u URI”;
Thansks用于响应。你可以发布代码来获取联系人图像的URI吗。?