图片缩略图在文件夹上显示

andre0122 2011-08-22 02:23:08
怎么样能在一个文件夹上显示文件夹里面的图片内容,就像windows装图片的文件夹那样,在文件夹上显示4个缩略图
...全文
305 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Y080Y 2011-12-15
  • 打赏
  • 举报
回复
楼主解决问题了吗?
sniffer12345 2011-08-23
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 andre0122 的回复:]

谢谢你,请问你是怎么import android.provider.DrmStore和import android.media.MediaMetadataRetriever的啊?
[/Quote]
eclipse下,ctrl+o
andre0122 2011-08-23
  • 打赏
  • 举报
回复
谢谢你,请问你是怎么import android.provider.DrmStore和import android.media.MediaMetadataRetriever的啊?
BadPattern 2011-08-22
  • 打赏
  • 举报
回复
另外,这个方法并不是拿来就能用的,这只是其中的代码片段,如果你有源码,你可以找camera应用下的GalleryPicker类
BadPattern 2011-08-22
  • 打赏
  • 举报
回复
其实就是得到文件夹里边图片缩略图,然后用canvas画在文件夹上。不过你要计算画的位置和间隔等信息。
BadPattern 2011-08-22
  • 打赏
  • 举报
回复
呵呵,我正好看过android1.5自带的图片浏览器,里边有一个方法正好是做这个事情的:
 private Bitmap makeMiniThumbBitmap(int width, int height, ImageManager.IImageList images) {
int count = images.getCount();
// We draw three different version of the folder image depending on the number of images in the folder.
// For a single image, that image draws over the whole folder.
// For two or three images, we draw the two most recent photos.
// For four or more images, we draw four photos.
final int padding = 4;
int imageWidth = width;
int imageHeight = height;
int offsetWidth = 0;
int offsetHeight = 0;

imageWidth = (imageWidth - padding) / 2; // 2 here because we show two images
imageHeight = (imageHeight - padding) / 2; // per row and column

final Paint p = new Paint();
final Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas c = new Canvas(b);

final Matrix m = new Matrix();

// draw the whole canvas as transparent
p.setColor(0x00000000);
c.drawPaint(p);

// draw the mask normally
p.setColor(0xFFFFFFFF);
mFrameGalleryMask.setBounds(0, 0, width, height);
mFrameGalleryMask.draw(c);

Paint pdpaint = new Paint();
pdpaint.setXfermode(new android.graphics.PorterDuffXfermode(
android.graphics.PorterDuff.Mode.SRC_IN));

pdpaint.setStyle(Paint.Style.FILL);
c.drawRect(0, 0, width, height, pdpaint);

for (int i = 0; i < 4; i++) {
if (mPausing) {
return null;
}

Bitmap temp = null;
ImageManager.IImage image = i < count ? images.getImageAt(i) : null;

if (image != null) {
temp = image.miniThumbBitmap();
}

if (temp != null) {
if (ImageManager.isVideo(image)) {
Bitmap newMap = temp.copy(temp.getConfig(), true);
Canvas overlayCanvas = new Canvas(newMap);
int overlayWidth = mVideoOverlay.getIntrinsicWidth();
int overlayHeight = mVideoOverlay.getIntrinsicHeight();
int left = (newMap.getWidth() - overlayWidth) / 2;
int top = (newMap.getHeight() - overlayHeight) / 2;
Rect newBounds = new Rect(left, top, left + overlayWidth, top + overlayHeight);
mVideoOverlay.setBounds(newBounds);
mVideoOverlay.draw(overlayCanvas);
temp.recycle();
temp = newMap;
}

Bitmap temp2 = ImageLoader.transform(m, temp, imageWidth, imageHeight, true);
if (temp2 != temp)
temp.recycle();
temp = temp2;
}

Bitmap thumb = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888);
Canvas tempCanvas = new Canvas(thumb);
if (temp != null)
tempCanvas.drawBitmap(temp, new Matrix(), new Paint());
mCellOutline.setBounds(0, 0, imageWidth, imageHeight);
mCellOutline.draw(tempCanvas);

placeImage(thumb, c, pdpaint, imageWidth, padding, imageHeight, padding, offsetWidth, offsetHeight, i);

thumb.recycle();

if (temp != null)
temp.recycle();
}

return b;
}

80,348

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧