Add vertical spacing to emoji sprites
Downsampling on low-dpi devices led to 1px bleeds between sprite areas. Fixes #3203 Closes #3206 // FREEBIE
Before Width: | Height: | Size: 346 KiB After Width: | Height: | Size: 347 KiB |
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 436 KiB |
Before Width: | Height: | Size: 511 KiB After Width: | Height: | Size: 515 KiB |
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 273 KiB |
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 315 KiB |
@ -50,11 +50,13 @@ public class EmojiProvider {
|
|||||||
public static final double EMOJI_SMALL = 0.50;
|
public static final double EMOJI_SMALL = 0.50;
|
||||||
public static final int EMOJI_RAW_HEIGHT = 128;
|
public static final int EMOJI_RAW_HEIGHT = 128;
|
||||||
public static final int EMOJI_RAW_WIDTH = 136;
|
public static final int EMOJI_RAW_WIDTH = 136;
|
||||||
|
public static final int EMOJI_VERT_PAD = 8;
|
||||||
public static final int EMOJI_PER_ROW = 15;
|
public static final int EMOJI_PER_ROW = 15;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final double drawWidth;
|
private final double drawWidth;
|
||||||
private final double drawHeight;
|
private final double drawHeight;
|
||||||
|
private final double verticalPad;
|
||||||
private final Handler handler = new Handler(Looper.getMainLooper());
|
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
public static EmojiProvider getInstance(Context context) {
|
public static EmojiProvider getInstance(Context context) {
|
||||||
@ -74,6 +76,7 @@ public class EmojiProvider {
|
|||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
this.drawHeight = context.getResources().getDimension(R.dimen.emoji_drawer_size);
|
this.drawHeight = context.getResources().getDimension(R.dimen.emoji_drawer_size);
|
||||||
this.drawWidth = drawHeight * ((double)EMOJI_RAW_WIDTH) / EMOJI_RAW_HEIGHT;
|
this.drawWidth = drawHeight * ((double)EMOJI_RAW_WIDTH) / EMOJI_RAW_HEIGHT;
|
||||||
|
this.verticalPad = EMOJI_VERT_PAD * drawHeight / EMOJI_RAW_HEIGHT;
|
||||||
Log.w(TAG, "draw size: " + drawWidth + "x" + drawHeight);
|
Log.w(TAG, "draw size: " + drawWidth + "x" + drawHeight);
|
||||||
for (int i = 0; i < pages.length; i++) {
|
for (int i = 0; i < pages.length; i++) {
|
||||||
final EmojiPageBitmap page = new EmojiPageBitmap(i);
|
final EmojiPageBitmap page = new EmojiPageBitmap(i);
|
||||||
@ -156,9 +159,9 @@ public class EmojiProvider {
|
|||||||
|
|
||||||
canvas.drawBitmap(bmp,
|
canvas.drawBitmap(bmp,
|
||||||
new Rect((int)(row_index * width),
|
new Rect((int)(row_index * width),
|
||||||
(int)(row * height),
|
(int)(row * height + row * verticalPad),
|
||||||
(int)((row_index + 1) * width),
|
(int)((row_index + 1) * width),
|
||||||
(int)((row + 1) * height)),
|
(int)((row + 1) * height + row * verticalPad)),
|
||||||
b,
|
b,
|
||||||
paint);
|
paint);
|
||||||
}
|
}
|
||||||
|