Home
Previous Nextcpmlip.h
Libraries
cpmlip.lib, cpmlip.dll.
Append
sdl.dll, sdl_ttf.dll, iconv.dll, fontlayer.dll, tracklayer.dll, videorender.dll.
Tutorial
Step 1: Call EM_Init to initialize CPMLIP as following example.
┅
LPTSTR lpBuffer = (LPTSTR)(new char[256]);
GetCurrentDirectory(256,lpBuffer);
EM_Init(lpBuffer);
delete []lpBuffer;
┅
Step 2: Set parent window. For showing directly,you must set the SDL window in your application program's view window. This you should call EM_SetParentWnd as following codes.More see the sample of "demovc".
BOOL CDemovcApp::InitInstance()
{
┅
char* pPopTitle = "Demovc(Cross Platform Multiple Layer Image Process SDK)";
m_pMainWnd->SetWindowText(pPopTitle);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
LPTSTR lpBuffer = (LPTSTR)(new char[256]);
GetCurrentDirectory(256,lpBuffer);
EM_Init(lpBuffer);
delete []lpBuffer;CString str;
g_pMyView1->GetWindowText(str);
char* pParentTitle = str.GetBuffer(str.GetLength());
EM_SetParentWnd(pPopTitle,pParentTitle);
┅
return TRUE;
}
Step 3: Call EM_SetPeekMessageFunction to set a function which can peek mouse messages and keyboard events.
Step 4: To process texts you should call EM_GetTTFFaceName to create a font table which contains file names of all system fonts and all font's face names. Maybe you will show them in your font dialog, but prior thing is that it will create a same table in "fontlayer.dll", so that CPMLIP can create different images with different fonts. Give a exameple:
//---------------------------------------------------------------------------
//Create font table#define MAX_FONT_COUNT 512
#define MAX_FACENAME 100
static EM_FontTable g_fonttable[MAX_FONT_COUNT];
static int g_fontcount = 0;
void CreateFontTable(){
#ifdef WIN32 // for windows
LPITEMIDLIST pidl;
LPMALLOC pShellMalloc;
char szDir[MAX_PATH];
char filespec[MAX_PATH];
long hFile;
_finddata_t fileinfo;
if(SUCCEEDED(SHGetMalloc(&pShellMalloc))){
if(SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_FONTS, &pidl))){
if(SHGetPathFromIDList(pidl, szDir)) {
int len = strlen(szDir);
if (szDir[len-1] != '\\')
strcat(szDir,"\\");
}
pShellMalloc->Free(pidl);
}
pShellMalloc->Release();
}
strcpy(filespec, szDir);
strcat(filespec, "*.ttf");
if ((hFile = _findfirst(filespec, &fileinfo)) != -1){
do{
if (!(fileinfo.attrib & _A_SUBDIR)){
char filename[MAX_PATH];
strcpy(filename, szDir);
strcat(filename, fileinfo.name);
char pfacename[MAX_FACENAME];
EM_GetTTFFaceName(filename, pfacename);
int exist = 0;
for(int i = 0; i < g_fontcount; i ++){
if(strcmp(pfacename , g_fonttable[i].name) == 0)
exist = 1;
}
if(exist == 0){
strcpy(g_fonttable[g_fontcount].path, filename);
strcpy(g_fonttable[g_fontcount].name, pfacename);
g_fontcount++;
}
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
#else
#endif
}