mirror of https://github.com/axmolengine/axmol.git
Merge commit 'fad68460540a7f924bad3e0c46391377fc26ee63' into lua
This commit is contained in:
commit
0530d21725
|
@ -1,6 +1,6 @@
|
|||
# set params
|
||||
ANDROID_NDK_ROOT=/workspace/android-dev/android-ndk-r5
|
||||
COCOS2DX_ROOT=/workspace/cocos2d-x
|
||||
ANDROID_NDK_ROOT=/cygdrive/e/android-ndk-r5
|
||||
COCOS2DX_ROOT=/cygdrive/d/Work7/cocos2d-x
|
||||
|
||||
GAME_ROOT=$COCOS2DX_ROOT/HelloLua
|
||||
GAME_ANDROID_ROOT=$GAME_ROOT/android
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package org.cocos2dx.lib;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
|
||||
public class Cocos2dxBitmap{
|
||||
public static void createTextBitmap(String content, int fontSize){
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setTextSize(fontSize);
|
||||
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int h = (int)Math.ceil(fm.descent - fm.ascent) + 2;
|
||||
int w = (int)Math.ceil(paint.measureText(content, 0, content.length()));
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.drawText(content, 0, h, paint);
|
||||
|
||||
initNativeObject(bitmap);
|
||||
}
|
||||
|
||||
private static void initNativeObject(Bitmap bitmap){
|
||||
byte[] pixels = getPixels(bitmap);
|
||||
if (pixels == null){
|
||||
return;
|
||||
}
|
||||
|
||||
nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels);
|
||||
}
|
||||
|
||||
private static byte[] getPixels(Bitmap bitmap){
|
||||
if (bitmap != null){
|
||||
byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4];
|
||||
ByteBuffer buf = ByteBuffer.wrap(pixels);
|
||||
buf.order(ByteOrder.nativeOrder());
|
||||
bitmap.copyPixelsToBuffer(buf);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static native void nativeInitBitmapDC(int width, int height, byte[] pixels);
|
||||
}
|
|
@ -9,14 +9,14 @@
|
|||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
WorkingDirectory="$(ProjectDir)Resource\"
|
||||
WorkingDirectory="$(ProjectDir)..\Resource\"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
WorkingDirectory="$(ProjectDir)Resource\"
|
||||
WorkingDirectory="$(ProjectDir)..\Resource\"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
|
|
|
@ -25,6 +25,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua\win32\HelloLua.win32.vcproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "lua\liblua.vcproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}"
|
||||
|
|
|
@ -107,19 +107,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \
|
|||
$(LOCAL_PATH)/platform/third_party/android/iconv \
|
||||
$(LOCAL_PATH)/platform/third_party/android/libpng \
|
||||
$(LOCAL_PATH)/platform/third_party/android/libxml2 \
|
||||
$(LOCAL_PATH)/platform/third_party/android/libjpeg \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/core \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/animator \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/config \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/effects \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/images \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/pdf \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/ports \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/svg \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/text \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/utils \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/views \
|
||||
$(LOCAL_PATH)/platform/third_party/android/skia/xml
|
||||
$(LOCAL_PATH)/platform/third_party/android/libjpeg
|
||||
|
||||
|
||||
LOCAL_CFLAGS := -DUSE_FILE32API
|
||||
|
|
Loading…
Reference in New Issue