--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/c9357edf-2e57-4803-ae32-36e330d6ec50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<resources>
<dimen name="image_size">64dp</dimen>
</resources>
<ImageView android:layout_width="@dimen/image_size" android:layout_height="@dimen/image_size" ... />
int size = context.getResources().getDimensionPixelSize(R.dimen.image_size) / 2; // 32 dp
.override(size, size)
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/7b56de91-5ccd-4a26-bb27-a51ad98147b2%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/a7dc9f0e-92c9-4c3e-be3a-7a362a58ae19%40googlegroups.com.
Glide.with(mContext)
.load(item.ImageRequest)
.sizeMultiplier(0.5f)
.fitCenter()
.into(holder.image);
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/17137e59-3a19-4b0f-9153-6c1162c538e0%40googlegroups.com.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="@dimen/listItemHeightTwoLines">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/listItemHeightTwoLines"
android:layout_height="match_parent"
android:scaleType="center" />
<de.stanwood.onair.phonegap.controls.SimpleProgress
android:id="@+id/progress"
android:layout_toRightOf="@id/image"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:background="@color/lightRed"
android:layout_marginLeft="1dp" />
<TextView
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:id="@+id/title"
style="@style/Title"
android:layout_toRightOf="@id/progress"
android:paddingLeft="@dimen/padding"
android:paddingRight="@dimen/padding"
android:paddingTop="@dimen/padding" />
<TextView
android:id="@+id/subhead"
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
style="@style/Subhead"
android:layout_below="@id/title"
android:layout_toRightOf="@id/progress"
android:paddingLeft="@dimen/padding"
android:paddingRight="@dimen/padding" />
</RelativeLayout>
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/b9ba4cc4-2c6d-4c8d-9e60-ac069e2ff0fc%40googlegroups.com.
fullRequest
.load(current)
.sizeMultiplier(0.1f)
.centerCrop()
.into(imageView);
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:scaleType="center"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/image_description" />
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/9f34c266-decd-47be-b35f-856e4609e7ec%40googlegroups.com.
new SquaringDrawable(resource, view.getWidth());
new SquaringDrawable(resource, resource.getIntrinsicWidth());
@SuppressWarnings("unchecked") ImageViewTarget<GlideDrawable> target =
(ImageViewTarget<GlideDrawable>) (ImageViewTarget) new DrawableImageViewTarget(imageView);
.into(target);
public void ImageView.setImageDrawable(Drawable drawable) {....
if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) {
requestLayout();
}
Tested with dontAnimate() but the problem is still present.
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/b25bd5c3-ae47-415d-8183-1edc9d06db0c%40googlegroups.com.
protected Bitmap transform(BitmapPool bitmapPool, Bitmap toTransform, int width, int height) {
int dstWidth=(int) ((float)width*0.5f);
int dstHeight=(int) ((float)height*0.5f);
final float srcAspect = (float) toTransform.getWidth() / (float) toTransform.getHeight();
final float dstAspect = (float) dstWidth / (float) dstHeight;
Rect dst;
if (srcAspect > dstAspect) {
dst= new Rect(0, 0, dstWidth, (int) (dstWidth / srcAspect));
} else {
dst= new Rect(0, 0, (int) (dstHeight * srcAspect), dstHeight);
}
dst.offsetTo((width-dst.width())/2,(height-dst.height())/2);
Bitmap recycled = bitmapPool.get(width,height, toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888);
final Bitmap result;
if (recycled != null) {
result = recycled;
} else {
result = Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888);
}
result.setHasAlpha(toTransform.hasAlpha());
Canvas canvas = new Canvas(result);
canvas.drawARGB(255,255,255,255);
Rect src=new Rect(0,0,toTransform.getWidth(),toTransform.getHeight());
canvas.drawBitmap(toTransform, src, dst, new Paint(Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG));
if (recycled != null && recycled != result && !bitmapPool.put(recycled)) {
recycled.recycle();
}
return result;
}
:) that's a surprise, you said you won't be using it, welcome back!
Other than some micro-refactors/suggestions, it looks good to me. Here they are in order of importance:
1. performance
Use pool.getDirty when you'll draw over the whole image, like you do here with drawARGB(). (See doc of method)
2. dither
I don't think you need that paint flag, as I remember from its doc it is only useful if the source image has higher depth than the target, which should never happen in your case (because of fallback to 8888).
3. recycled
I couldn't think of a way that last recycle() will ever be called (maybe it's too early in the morning). As I see recycled is always either null or the same as result, so that last if is unnecessary, which also leads to recycled variable being unnecessary, so you can just initialise result from the pool and if that was null, create a new one so you always have a nonnull result.
4. final
It's confusing that only half of the variables are final, but none of them are reassigned. Either make all of them final or none (I prefer this one).
5. consistent formatting
You should execute a Format Code IDE action on your code :) You can have save actions in Eclipse so that it is automatic and IDEA should do it automatically too. It's still worth learning the shortcut for it and using it as often as CTRL+S.
Have a nice day!
+Robi
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/3d8ce614-3481-456b-90d4-496cd47eb503%40googlegroups.com.
I think it's a little wasteful, but if you're really keen on implementing that requirement and it works, you've answered it yourself.
Did you try the solution/alternative from my detailed email?
As to centerCrop, I don't see any recycle calls in TransformUtils (v3.6.0). There is one in CenterCrop.transform, but that's because TransformUtils may or may not use the bitmap from pool (there are more possibilities there with more ifs). CenterCrop essentially treats TransformUtils as black box, so it can evolve more easily.
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/fa5f7589-c45c-4252-85b0-4481eef19ad5%40googlegroups.com.
It should be transparent based on LruBitmapPool.get. I think the problem here is that you want a transparent image as a result but you're using the config from source which is probably opaque because its source is a JPEG.
Try always using 8888:
Bitmap recycled = bitmapPool.get(width,height, Bitmap.Config.ARGB_8888);
...
result = Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888);
...
result.setHasAlpha(true); // probably not necessary
...
//- canvas.drawARGB(255,255,255,255);
I do the drawARGB() only to make the created bitmap not black.
Do you know a better solution for this ?
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/d38803bd-224b-4b9e-8f58-3acc9520d876%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/c3bcb044-f0d3-4fbd-87f9-00f364adc88b%40googlegroups.com.
> Did you try the solution/alternative from my detailed email?
Yes, working with asBitmap() works also, but I love the idea that glide will handle the animations.
>I think it's a little wasteful,
Why do you think so ?
Asking because performance matters :D
What is the prefered way doing this in case of performance ?
Doing a get() with transparent pixels or doing a getDirty() followed by a drawcolor?
--
You received this message because you are subscribed to the Google Groups "Glide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glidelibrary...@googlegroups.com.
To post to this group, send email to glidel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glidelibrary/c3bcb044-f0d3-4fbd-87f9-00f364adc88b%40googlegroups.com.