428 {
429 ViewGroup.LayoutParams lp = cursor.getLayoutParams();
430 if (pixels == null || width <= 0 || height <= 0)
431 {
432 cursor.setImageResource(R.drawable.ic_cursor);
433 ImageViewCompat.setImageTintList(cursor, ColorStateList.valueOf(cursorTint));
434 int s = getResources().getDimensionPixelSize(R.dimen.tp_cursor_size);
435 lp.width = s;
436 lp.height = s;
437 cursor.setLayoutParams(lp);
438 cursor.setTranslationX(0);
439 cursor.setTranslationY(0);
440 return;
441 }
442 Bitmap bmp = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
443 float scale = 40 * density / height;
444 if (scale < 1.2f)
445 scale = 1.2f;
446 if (scale > 3.0f)
447 scale = 3.0f;
448 ImageViewCompat.setImageTintList(cursor, null);
449
450 BitmapDrawable bd = new BitmapDrawable(getResources(), bmp);
451 bd.setFilterBitmap(false);
452 cursor.setImageDrawable(bd);
453 lp.width = Math.round(width * scale);
454 lp.height = Math.round(height * scale);
455 cursor.setLayoutParams(lp);
456
457 cursor.setTranslationX(-hotX * scale);
458 cursor.setTranslationY(-hotY * scale);
459 }