Skip to content

Commit

Permalink
fix #28, bitmap in android size should multipled by content scale factor
Browse files Browse the repository at this point in the history
  • Loading branch information
stubma committed Nov 13, 2013
1 parent b89ce4d commit f2bac7a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cocos2dx-common/java/org/cocos2dx/lib/RichLabelBitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,14 @@ public static void createRichLabelBitmap(String pString, final String pFontName,
try {
is = am.open(openSpan.imageName);
Bitmap bitmap = BitmapFactory.decodeStream(is);
if(openSpan.scaleX != 1 || openSpan.scaleY != 1) {
if(openSpan.scaleX != 1 || openSpan.scaleY != 1 || contentScaleFactor != 1) {
float dstW = openSpan.width != 0 ? (int)openSpan.width : (int)(bitmap.getWidth() * openSpan.scaleX);
float dstH = openSpan.height != 0 ? (int)openSpan.height : (int)(bitmap.getHeight() * openSpan.scaleY);
dstW *= contentScaleFactor;
dstH *= contentScaleFactor;
Bitmap scaled = Bitmap.createScaledBitmap(bitmap,
openSpan.width != 0 ? (int)openSpan.width : (int)(bitmap.getWidth() * openSpan.scaleX),
openSpan.height != 0 ? (int)openSpan.height : (int)(bitmap.getHeight() * openSpan.scaleY),
(int)dstW,
(int)dstH,
true);
bitmap.recycle();
bitmap = scaled;
Expand Down Expand Up @@ -557,7 +561,7 @@ public static void createRichLabelBitmap(String pString, final String pFontName,
c.translate(startX, startY);

// draw text
layout.draw(c);
layout.draw(c);

// draw again if stroke is enabled
if(stroke) {
Expand Down

0 comments on commit f2bac7a

Please sign in to comment.