如何从android中的图像url创建中心裁剪的缩略图图像

时间:2016-12-06 10:58:29

标签: android

我正在使用滑动库来加载我的图像,我正在显示整个图像,我想显示缩略图。怎么做?

SELECT DISTINCT id, resOfA, resOfB FROM t1 AS src
CROSS APPLY (
    SELECT TOP 1 (resA.maxAmt-resA.minAmt) AS resOfA FROM t1 
    CROSS APPLY (
                    SELECT (SELECT amount FROM t1 WHERE id=src.id AND date = (SELECT max(date) FROM t1 WHERE id=src.id)) AS maxAmt, 
                     (SELECT amount FROM t1 WHERE id=src.id AND date = (SELECT min(date) FROM t1 WHERE id=src.id)) AS minAmt
                ) AS resA
    WHERE src.id = id       
)
CROSS APPLY (
    SELECT TOP 1 (resB.sumAmt - resB.minAmt) as resOfB FROM t2
    CROSS APPLY (
                    SELECT (select SUM(amount) FROM t2 WHERE id=src.id) as maxAmt, 
                    (SELECT amount FROM t2 where id=src.id AND date = (SELECT min(date) FROM t2 WHERE id=src.id)) AS minAmt, 
                ) AS resB   
    WHERE src.id = id
)

我尝试过scaleType:fitXY和scaleType:centerCrop没什么用。

Glide.with(context)
            .load(resized)
            .centerCrop()
            .placeholder(R.drawable.default_review)
            .crossFade().fitCenter()
            .into(triviaImage);

enter image description here

3 个答案:

答案 0 :(得分:0)

您必须使用override(width, height),如下所示:

Glide.with(context)
    .load(resized)
    .asBitmap()
    .override(400, 400) // smaller the size, lower the quality of Image
    .centerCrop()
    .error(R.drawable.image_error_placeholder)
    .into(triviaImage);

答案 1 :(得分:0)

试试这个,

Glide  
    .with( context )
    .load( resized )
    .thumbnail( 0.1f )
    .into( triviaImage);

答案 2 :(得分:0)

我通过这个解决了我的问题 -

 Glide.with(context)
                  .load(myImageUrl)
                  /*Here "myImageUrl" is the original image url*/
                  .thumbnail(Glide.with(context).load(myThumbImageUrl).centerCrop())
                  /*Here "myThumbImageUrl" is the thumb image url*/
                  .into(view);