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