|
Project Information
Featured
Downloads
Links
|
The project named agglib which provides simple interface for developer, such as pen,font,brush,DrawText, Ellipse,etc. The library is developped based on common language extension(CLE). Therefore it can be called from c/c++, java, python, lua, etc. The agglib is developed based on CLE. Using agglib : First Methodcopy share libraries of cle into libs/armeabi directory of your project, and copy SRPSAGGLibEngine.zip into assets directory. As follows:
and using following code to init cle and agglib import com.srplab.www.starcore.*;
StarCoreFactoryPath.InitDefault(Runtime.getRuntime(),"/data/data/com.srpsagglib.drawexample"); // com.srpsagglib.drawexample is your package name.
AssetManager assetManager = getAssets();
try{
InputStream dataSource = assetManager.open("SRPSAGGLibEngine.zip");
StarCoreFactoryPath.InstallDefault(dataSource, false);
}
catch(IOException e ){
}
....
StarCoreFactory starcore;
StarSrvGroupClass SrvGroup;
StarCoreFactory starcore= StarCoreFactory.GetFactory();
StarServiceClass Service=starcore._InitSimple("test","123",0,0,StarCoreFactoryPath.StarCoreOperationPath+"/SRPSAGGLibEngine");
...Using agglib : Second MethodDownload share libraries of cle from network dynamically. Using this method, install package will be smaller. As follows: import com.srplab.www.starcore.*;
import com.srplab.netinst.*;
starcore_net_inst.InstallZipFile(this,"libstarcore.so","http://www.srplab.com/android/starcore_armeabi_r3.zip", "/data/data/com.srpsagglib.drawexample_netinst/files");
starcore_net_inst.InstallZipFile(this,"SRPSAGGLibEngine/SRPSAGGLibBasicModule_android.so","http://www.srplab.com/android/SRPSAGGLibEngine_r1.zip", "/data/data/com.srpsagglib.drawexample_netinst/files");
StarCoreFactoryPath.StarCoreShareLibraryPath = "/data/data/com.srpsagglib.drawexample_netinst/files";
StarCoreFactoryPath.StarCoreOperationPath = "/data/data/com.srpsagglib.drawexample_netinst/files";
....
StarCoreFactory starcore;
StarSrvGroupClass SrvGroup;
StarCoreFactory starcore= StarCoreFactory.GetFactory();
StarServiceClass Service=starcore._InitSimple("test","123",0,0,StarCoreFactoryPath.StarCoreOperationPath+"/SRPSAGGLibEngine");
...Examples
full examples code can be got from download page StarCoreFactory starcore= StarCoreFactory.GetFactory();
starcore._InitCore(true,true,false,true,"",0,"",0);
StarServiceClass Service=starcore._InitSimple("test","123",0,0,StarCoreFactoryPath.StarCoreOperationPath+"/SRPSAGGLibEngine");
StarSrvGroupClass SrvGroup = (StarSrvGroupClass)Service._Get("_ServiceGroup");
StarBinBufClass ImgBuf = SrvGroup._NewBinBuf();
StarObjectClass Agg = Service._GetObject("SAggCanvasClass")._New();
Agg._Active();
Agg._Call("SetImg",800,600,ImgBuf);
StarObjectClass Brush = Service._GetObject("SAggColorBrushClass")._New();
Brush._Set("Color",0x0000FF);
Brush._Set("SmoothType",Service._Getint("SAGG_LINE_SMOOTHTYPE_BSP"));
StarObjectClass Font = Service._GetObject("SAggFontClass")._New();
Font._Set("DPI", 240);
Font._Set("Height",30);
Font._Set("FontName","/system/fonts/DroidSansFallback.ttf");
Agg._Call("DrawTextEx",Font,50,50,255,255,4259584,255,false,true,false,true,"http://www.srplab.com");
Agg._Call("DrawTextEx",Font,50,50,255,128,4259584,128,false,true,true,true,"http://www.srplab.com");
Agg._Call("DrawTextEx",Font,400,50,255,255,255,255,false,false,false,true,"http://www.srplab.com");
StarObjectClass Pen = Service._GetObject("SAggPenClass")._New();
Pen._Set("Width",3);
Pen._Set("Color",0xFF0000);
Pen._Set("Alpha",255);
Pen._Set("Type",1);
Pen._Set("DashLen",5);
Pen._Set("GapLen",2);
Pen._Set("SmoothType",Service._Getint("AGG_LINE_SMOOTHTYPE_CONTOUR"));
StarObjectClass Brush0 = Service._GetObject("SAggColorBrushClass")._New();
Brush0._Set("Color",0x0000FF);
Brush0._Set("SmoothType",Service._Getint("AGG_LINE_SMOOTHTYPE_CONTOUR"));
Agg._Call("Rect",Pen,50,100,150,150,true);
Agg._Call("FillRect",Brush0,175,100,270,150,true);
Agg._Call("Ellipse",Pen,350,125,50,25,50,true);
Agg._Call("FillEllipse",Brush0,475,125,50,25,50,true);
Agg._Call("Arc",Pen,600,125,50,25,45,135,true);
Agg._Call("FillArc",Brush0,725,125,50,25,45,135,true);
StarObjectClass Path = Service._GetObject("SAggPathClass")._New();
Path._Active();
Path._Call("MoveTo",50,175);
Path._Call("Curve3",100,275,150,225,true);
Path._Call("Curve3",200,175,250,275,true);
StarObjectClass Pen1 = Service._GetObject("SAggPenClass")._New();
Pen1._Set("Width",2);
Pen1._Set("Color",0xFF0000);
Pen1._Set("Alpha",255);
Pen1._Set("Type",1);
Pen1._Set("DashLen",2);
Pen1._Set("GapLen",2);
Pen1._Set("SmoothType",Service._Getint("AGG_LINE_SMOOTHTYPE_CURVE"));
Agg._Call("DrawPath",Pen1,Path,true);
StarObjectClass Path1 = Service._GetObject("SAggPathClass")._New();
Path1._Active();
Path1._Call("MoveTo",300,175);
Path1._Call("Curve3",350,275,400,225,true);
Path1._Call("Curve3",450,175,500,275,true);
Agg._Call("DrawTextOnPath",Font,Path1,"",Service._Getint("AGG_LINE_SMOOTHTYPE_CURVE"),255,255,false,true,"http://www.srplab.com");
Agg._Call("DrawTextOnPath",Font,Path1,"",Service._Getint("AGG_LINE_SMOOTHTYPE_CURVE"),255,128,true,true,"http://www.srplab.com");
StarObjectClass Brush1 = Service._GetObject("SAggColorSpanBrushClass")._New();
Brush1._Set("SmoothType",Service._Getint("SAGG_LINE_SMOOTHTYPE_BSP"));
Brush1._Set("StartPosX",40);
Brush1._Set("StartPosY",40);
Brush1._Set("GradientEnd",100);
Brush1._Set("Color","0.0,4294967295,0.2,4294901760,0.4,4278255360,0.8,255");
Agg._Call("FillPolygon",Brush1,new Object[]{100,300,300,300,300,400,100,400},true);
StarObjectClass Brush2 = Service._GetObject("SAggColorSpanBrushClass")._New();
Brush2._Set("SmoothType",Service._Getint("AGG_LINE_SMOOTHTYPE_CONTOUR"));
Brush2._Set("StartPosX",0);
Brush2._Set("StartPosY",50);
Brush2._Set("GradientEnd",200);
Brush2._Set("GradientType",Service._Getint("SAGG_GRADIENT_X"));
Brush2._Set("Color","0.0,4294967295,0.2,4294901760,0.4,4278255360,0.8,255");
Agg._Call("FillPolygon",Brush2,new Object[]{300,300,500,300,500,400,300,400},true);
StarObjectClass Font1 = Service._GetObject("SAggFontClass")._New();
Font1._Set("Height",50);
Font1._Set("FontName","/system/fonts/DroidSansFallback.ttf");
Object[] RetVaue = (Object[])Agg._Call("DrawTextEx",Font1,50,430,255,255,255,255,false,false,false,true,"我们Wrap of Anti-Grain Geomet for Android");
int pix[] = new int[800*600]; //bgra
ImgBuf._Read4(pix,0,800*600,3,2,1,0);
Bitmap bm = Bitmap.createBitmap(pix,800,600,Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Style.FILL);
canvas.drawBitmap(bm,0,0,paint);
SrvGroup._ClearService();Example in c++agglib can be called using c++ language. You can download header files from download page ,or create header files using star2h tools of cle. command line : star2h http://www.srplab.com/starservice/SRPSAGGLibEngine java code StarCoreFactory starcore= StarCoreFactory.GetFactory();
starcore._InitCore(true,true,false,true,"",0,"",0);
StarServiceClass Service=starcore._InitSimple("test","123",0,0,StarCoreFactoryPath.StarCoreOperationPath+"/SRPSAGGLibEngine");
StarSrvGroupClass SrvGroup = (StarSrvGroupClass)Service._Get("_ServiceGroup");
StarBinBufClass ImgBuf = SrvGroup._NewBinBuf();
StarObjectClass Agg = Service._GetObject("SAggCanvasClass")._New("AggObject"); //AggObject is name, c++ will use this name to find the object
Agg._Active();
Agg._Call("SetImg",800,600,ImgBuf);
Agg._Call("FillBack");
//---call c++ sharelib to draw
Service._CheckPassword(false);
Service._DoFile("","/data/data/com.srpsagglib.drawexample_c/lib/libdraw_c.so","");
int pix[] = new int[800*600]; //bgra
ImgBuf._Read4(pix,0,800*600,3,2,1,0);
Bitmap bm = Bitmap.createBitmap(pix,800,600,Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Style.FILL);
canvas.drawBitmap(bm,0,0,paint);
SrvGroup._ClearService();c++ code #include "SRPSAGGLibEngine_VSClass.h"
class ClassOfSAggCanvasClass *Agg;
class ClassOfSRPInterface *SRPInterface;
class ClassOfSAggColorBrushClass *Brush;
class ClassOfSAggFontClass *Font;
class ClassOfSAggPenClass *Pen;
class ClassOfSAggColorBrushClass *Brush0;
VS_BOOL StarCoreService_Init(class ClassOfStarCore *starcore)
{
class ClassOfBasicSRPInterface *BasicSRPInterface;
//--init star core
BasicSRPInterface = starcore ->GetBasicInterface();
SRPInterface = BasicSRPInterface ->GetSRPInterface(BasicSRPInterface->QueryActiveService(NULL),"","");
// GetObjectEx is used to get object defined by java
Agg = new class ClassOfSAggCanvasClass(SRPInterface,SRPInterface->GetObjectEx(NULL,"AggObject"));
Brush = new class ClassOfSAggColorBrushClass(SRPInterface);
Brush ->Put_Color(0x0000FF);
Brush ->Put_SmoothType(SAGG_LINE_SMOOTHTYPE_BSP);
Font = new class ClassOfSAggFontClass(SRPInterface);
Font -> Put_Height(30);
Font -> Put_FontName("/system/fonts/DroidSansFallback.ttf");
Agg -> C_DrawTextEx(Font->GetSRPObject(),50,50,255,255,4259584,255,false,true,false,NULL,true,"http://www.srplab.com");
Agg -> C_DrawTextEx(Font->GetSRPObject(),50,50,255,128,4259584,128,false,true,true,NULL,true,"http://www.srplab.com");
Agg -> C_DrawTextEx(Font->GetSRPObject(),400,50,255,255,255,255,false,false,false,NULL,true,"http://www.srplab.com");
Pen = new ClassOfSAggPenClass(SRPInterface);
Pen->Put_Width(3);
Pen->Put_Color(0xFF0000);
Pen->Put_Alpha(255);
Pen->Put_Type(1);
Pen->Put_DashLen(5);
Pen->Put_GapLen(2);
Pen->Put_SmoothType(SAGG_LINE_SMOOTHTYPE_CONTOUR);
Brush0 = new class ClassOfSAggColorBrushClass(SRPInterface);
Brush0 ->Put_Color(0x0000FF);
Brush0 ->Put_SmoothType(SAGG_LINE_SMOOTHTYPE_CONTOUR);
Agg -> C_Rect(Pen->GetSRPObject(),50,100,150,150,NULL,true);
Agg -> C_FillRect(Brush0->GetSRPObject(),175,100,270,150,NULL,true);
Agg -> C_Ellipse(Pen->GetSRPObject(),350,125,50,25,50,NULL,true);
Agg -> C_FillEllipse(Brush0->GetSRPObject(),475,125,50,25,50,NULL,true);
Agg -> C_Arc(Pen->GetSRPObject(),600,125,50,25,45,135,NULL,true);
Agg -> C_FillArc(Brush0->GetSRPObject(),725,125,50,25,45,135,NULL,true);
return VS_TRUE;
}
void StarCoreService_Term(class ClassOfStarCore *starcore)
{
SRPInterface ->Print("Sharelib Released");
Agg ->Release();
Brush ->Release();
Font ->Release();
Pen ->Release();
Brush0 ->Release();
SRPInterface -> Release();
return;
}
Android.mk LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Here we give our module name and sourcefile(s)
LOCAL_CFLAGS += -Wno-write-strings -DENV_ANDROID
LOCAL_CPPFLAGS += -Wno-write-strings -fexceptions -DENV_ANDROID
LOCAL_LDFLAGS += -Wno-write-strings -DENV_ANDROID
LOCAL_C_INCLUDES += ../../../../../source/include
#--------source file
MODULE_CXXSRCS := main.cpp SRPGLESEngine_UUIDDef.cpp SRPGLESEngine_VSClass.cpp
LOCAL_SRC_FILES := ${MODULE_CXXSRCS}
LOCAL_LDLIBS := ../../../../../android/workspace/libs/armeabi/libstarlib.a
LOCAL_MODULE := CRender
include $(BUILD_SHARED_LIBRARY)
|