325 {
326 ViewGroup.LayoutParams lp = cursor.getLayoutParams();
327 if (pixels == null || width <= 0 || height <= 0)
328 {
329 cursor.setImageResource(R.drawable.ic_cursor);
330 ImageViewCompat.setImageTintList(cursor, ColorStateList.valueOf(cursorTint));
331 int s = getResources().getDimensionPixelSize(R.dimen.tp_cursor_size);
332 lp.width = s;
333 lp.height = s;
334 cursor.setLayoutParams(lp);
335 cursor.setTranslationX(0);
336 cursor.setTranslationY(0);
337 return;
338 }
339 Bitmap bmp = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
340 float scale = 40 * density / height;
341 if (scale < 1.2f)
342 scale = 1.2f;
343 if (scale > 3.0f)
344 scale = 3.0f;
345 ImageViewCompat.setImageTintList(cursor, null);
346
347 BitmapDrawable bd = new BitmapDrawable(getResources(), bmp);
348 bd.setFilterBitmap(false);
349 cursor.setImageDrawable(bd);
350 lp.width = Math.round(width * scale);
351 lp.height = Math.round(height * scale);
352 cursor.setLayoutParams(lp);
353
354 cursor.setTranslationX(-hotX * scale);
355 cursor.setTranslationY(-hotY * scale);
356 }