Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

I want to Draw some chars on the IBitmap.

first I get device bitmap,and create a compatible bitmap with it,
then I create an IFont with ClsID AEECLSID_FONT_BASIC6, and then I call the function IFONT_DrawText to draw on the compatible bitmap. at last I bitblt the bitmap to display.

but the screen only display some little rectangle at the text position.

the same circumstance occurs in both emulator and device.

I used the kyocera KZ-820
When I create an IFont with clsID AEECLSID_FONT_ZHCN12,I Succeed.
When I Call IDISPLAY_DrawText function to write the text in the screen , I succeed;
But When I Call IFONT_DrawText function to write on the bitmap and then bitblt the bitmap to the display , I failed. there is nothing in the screen.

I used the kyocera KZ-820
When I create an IFont with clsID AEECLSID_FONT_ZHCN12,I Succeed.
When I Call IDISPLAY_DrawText function to write the text in the screen , I succeed;
But When I Call IFONT_DrawText function to write on the bitmap and then bitblt the bitmap to the display , I failed. there is nothing in the screen.

There is a big difference between IDISPLAY_DrawText and IFONT_DrawText.
First one draws text onto the on-screen bitmap whereas the later one is capable to drawing text onto the off-screen bitmap.
In order to use IFONT_DrawText you need use device dependent bitmap(I guess this step you are doing correctly, getting a device dependent bitmap and then create compatible bitmap). If you create Device independent bitmap, it would not work, because BREW device independent bitmap does not implement drawing funcitonalities.
Please note that IFONT_DrawText would be successful, if the phone OEM implements drawing functionalities in your device dependent bitmap. Anyway, you can try to implement system font drawing mechanism by using the following steps:
1. Select the font type face.
2. Select the font type
3. Call create instance of IFont interface.
4. Create a clone of my default display
5. Save the destination bitmap of the cloned display.
6. Now set your compatible bitmap as the destination for the cloned display
7. Now call IDISPLAY_SetFont to set the newly created font for the cloned display.
8. Now prepare all the parameters for IFont_DrawText (like string, length, foregroundcolor, backgroundcolor, clipRect etc)
9. Now Call IFont_DrawText on the bitmap (the bitmap onto which Flash renders) with the last parameter as IDF_TEXT_TRANSPARENT
10. Now restore the old bitmap for cloned display.
11. Release the newly created font and the release cloned display.
I have used cloned display instead of default display, because in certain phone I found that it causes crash for some unknown reason to me. You can use default display, if it does not cause any problem for you.
ruben

There is a big difference between IDISPLAY_DrawText and IFONT_DrawText.
First one draws text onto the on-screen bitmap whereas the later one is capable to drawing text onto the off-screen bitmap.
In order to use IFONT_DrawText you need use device dependent bitmap(I guess this step you are doing correctly, getting a device dependent bitmap and then create compatible bitmap). If you create Device independent bitmap, it would not work, because BREW device independent bitmap does not implement drawing funcitonalities.
Please note that IFONT_DrawText would be successful, if the phone OEM implements drawing functionalities in your device dependent bitmap. Anyway, you can try to implement system font drawing mechanism by using the following steps:
1. Select the font type face.
2. Select the font type
3. Call create instance of IFont interface.
4. Create a clone of my default display
5. Save the destination bitmap of the cloned display.
6. Now set your compatible bitmap as the destination for the cloned display
7. Now call IDISPLAY_SetFont to set the newly created font for the cloned display.
8. Now prepare all the parameters for IFont_DrawText (like string, length, foregroundcolor, backgroundcolor, clipRect etc)
9. Now Call IFont_DrawText on the bitmap (the bitmap onto which Flash renders) with the last parameter as IDF_TEXT_TRANSPARENT
10. Now restore the old bitmap for cloned display.
11. Release the newly created font and the release cloned display.
I have used cloned display instead of default display, because in certain phone I found that it causes crash for some unknown reason to me. You can use default display, if it does not cause any problem for you.
ruben

Quote:Originally posted by coffea
[B]but the screen only display some little rectangle at the text position.
Do you mean that you see one rectangle, which encloses the area where the text should be? That would happen if you used the same color for the foreground and the background.
If you posted the relevant part of your code, it would help me in diagnosing the problem.

Quote:Originally posted by coffea
[B]but the screen only display some little rectangle at the text position.
Do you mean that you see one rectangle, which encloses the area where the text should be? That would happen if you used the same color for the foreground and the background.
If you posted the relevant part of your code, it would help me in diagnosing the problem.

TO markb
I mean that every word became one little rectangle:(
My code fregment:
//create bitmap
IDISPLAY_GetDeviceBitmap(pMe->m_pIDisplay, &pSysBitmap,);
IBITMAP_CreateCompatibleBitmap(pSysBitmap, &pBitmap, 96, 113);
//create font
ISHELL_CreateInstance( pMe->m_pIShell, AEECLSID_FONT_FIXED4X6 /*AEECLSID_FONT_ZHCN12*/, (void**)( &pIFont ) );
//convert to unicode
psTextBuf = (AECHAR*) MALLOC( (STRLEN(pstr)+4) * sizeof( AECHAR ) );
MEMSET(psTextBuf,0x00,(STRLEN(pstr)+4) * sizeof( AECHAR ));
// psTextBuf = STRTOWSTR(pcTS,pTest,(STRLEN(pstr)+4) * sizeof( AECHAR ));
ConvertText(pstr, STRLEN(pstr), (byte*)psTextBuf, STRLEN(pstr), pMe);
//draw text
iRet = IFONT_DrawText( pIFont,
pBitmap,
10,
10,
(AECHAR*)psTextBuf,
STRLEN(pstr)/2+1,
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,0,0)),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,255,0)),
&rRect,
IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT );
// IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT | IDF_TEXT_TRANSPARENT );
IDISPLAY_BitBlt(pMe->m_pIDisplay,0,0,96,113,pBitmap,0,0,AEE_RO_COPY);
IDISPLAY_Update(pMe->m_pIDisplay);
FREE(psTextBuf );
IFONT_Release(pIFont);

TO markb
I mean that every word became one little rectangle:(
My code fregment:
//create bitmap
IDISPLAY_GetDeviceBitmap(pMe->m_pIDisplay, &pSysBitmap,);
IBITMAP_CreateCompatibleBitmap(pSysBitmap, &pBitmap, 96, 113);
//create font
ISHELL_CreateInstance( pMe->m_pIShell, AEECLSID_FONT_FIXED4X6 /*AEECLSID_FONT_ZHCN12*/, (void**)( &pIFont ) );
//convert to unicode
psTextBuf = (AECHAR*) MALLOC( (STRLEN(pstr)+4) * sizeof( AECHAR ) );
MEMSET(psTextBuf,0x00,(STRLEN(pstr)+4) * sizeof( AECHAR ));
// psTextBuf = STRTOWSTR(pcTS,pTest,(STRLEN(pstr)+4) * sizeof( AECHAR ));
ConvertText(pstr, STRLEN(pstr), (byte*)psTextBuf, STRLEN(pstr), pMe);
//draw text
iRet = IFONT_DrawText( pIFont,
pBitmap,
10,
10,
(AECHAR*)psTextBuf,
STRLEN(pstr)/2+1,
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,0,0)),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,255,0)),
&rRect,
IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT );
// IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT | IDF_TEXT_TRANSPARENT );
IDISPLAY_BitBlt(pMe->m_pIDisplay,0,0,96,113,pBitmap,0,0,AEE_RO_COPY);
IDISPLAY_Update(pMe->m_pIDisplay);
FREE(psTextBuf );
IFONT_Release(pIFont);

Thanks ruben
Now I have succeeded in drawing the char in the bitmap by using the cloned display.

Thanks ruben
Now I have succeeded in drawing the char in the bitmap by using the cloned display.

Hi
coffea;
I am also trying to draw text in bitmap, but it is not. I have red u r reply, can u send the ur code to to it. I have written the codde accroding to the steps told by rubben but it is not working.
My code is as.
// Create Bitmap
IDISPLAY_GetDeviceBitmap(pApp->a.m_pIDisplay, &pApp->m_pDevBitmap);
IBITMAP_CreateCompatibleBitmap(pApp->m_pDevBitmap, &pApp->m_pIBitmap, 100, 100);
IDISPLAY_SetDestination(pApp->a.m_pIDisplay, pApp->m_pIBitmap);
// Create font
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_FONT_FIXED4X6, (void**)(&pApp->m_pIFont));
if(!pApp->m_pIFont)
{
DBGPRINTF("Can not create the font !");
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);
return TRUE;
}
rect.x = rect.y = 0;
rect.dx = rect.dy = 100;
IDISPLAY_SetFont(pApp->a.m_pIDisplay, AEE_FONT_BOLD, pApp->m_pIFont);
iResult = IFONT_DrawText(pApp->m_pIFont, pApp->m_pIBitmap, 50, 50, wszText, -1,
IBITMAP_RGBToNative(pApp->m_pIBitmap, MAKE_RGB(255, 0, 0)),
IBITMAP_RGBToNative(pApp->m_pIBitmap, MAKE_RGB(0, 0, 0)), &rect,
IDF_TEXT_TRANSPARENT );
if(iResult != SUCCESS)
{
DBGPRINTF("Can not Draw the text in Bitmap !");
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);
return TRUE;
}
IDISPLAY_BitBlt(pApp->a.m_pIDisplay, 0, 0, 100,100,pApp->m_pIBitmap, 0, 0, AEE_RO_TRANSPARENT);
IDISPLAY_Update(pApp->a.m_pIDisplay);
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);

Hi
coffea;
I am also trying to draw text in bitmap, but it is not. I have red u r reply, can u send the ur code to to it. I have written the codde accroding to the steps told by rubben but it is not working.
My code is as.
// Create Bitmap
IDISPLAY_GetDeviceBitmap(pApp->a.m_pIDisplay, &pApp->m_pDevBitmap);
IBITMAP_CreateCompatibleBitmap(pApp->m_pDevBitmap, &pApp->m_pIBitmap, 100, 100);
IDISPLAY_SetDestination(pApp->a.m_pIDisplay, pApp->m_pIBitmap);
// Create font
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_FONT_FIXED4X6, (void**)(&pApp->m_pIFont));
if(!pApp->m_pIFont)
{
DBGPRINTF("Can not create the font !");
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);
return TRUE;
}
rect.x = rect.y = 0;
rect.dx = rect.dy = 100;
IDISPLAY_SetFont(pApp->a.m_pIDisplay, AEE_FONT_BOLD, pApp->m_pIFont);
iResult = IFONT_DrawText(pApp->m_pIFont, pApp->m_pIBitmap, 50, 50, wszText, -1,
IBITMAP_RGBToNative(pApp->m_pIBitmap, MAKE_RGB(255, 0, 0)),
IBITMAP_RGBToNative(pApp->m_pIBitmap, MAKE_RGB(0, 0, 0)), &rect,
IDF_TEXT_TRANSPARENT );
if(iResult != SUCCESS)
{
DBGPRINTF("Can not Draw the text in Bitmap !");
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);
return TRUE;
}
IDISPLAY_BitBlt(pApp->a.m_pIDisplay, 0, 0, 100,100,pApp->m_pIBitmap, 0, 0, AEE_RO_TRANSPARENT);
IDISPLAY_Update(pApp->a.m_pIDisplay);
IFONT_Release(pApp->m_pIFont);
pApp->m_pIFont = NULL;
IBITMAP_Release(pApp->m_pIBitmap);
pApp->m_pIBitmap = NULL;
IBITMAP_Release(pApp->m_pDevBitmap);

If your device bitmap does not support drawing methods, then you will not be able to write text using IFONT interface.
ruben

If your device bitmap does not support drawing methods, then you will not be able to write text using IFONT interface.
ruben

Gopalmudaliar, it looks like you are drawing text to an offscreen bitmap, and then blitting this bitmap to itself. What you really need to do is blit it to the device bitmap. Eliminating the call to IDISPLAY_SetDestination() should fix that. Also, calling IDISPLAY_SetFont() appears to be unnecessary, since you are never using IDISPLAY_DrawText().

Gopalmudaliar, it looks like you are drawing text to an offscreen bitmap, and then blitting this bitmap to itself. What you really need to do is blit it to the device bitmap. Eliminating the call to IDISPLAY_SetDestination() should fix that. Also, calling IDISPLAY_SetFont() appears to be unnecessary, since you are never using IDISPLAY_DrawText().

tried to create a cloned display use"IDISPLAY_Clone()" and use IDISPLAY_SetDestination to related the bitmap and the clonedisplay, and save the old bitmap of clonedisplay.
then do what you want to do use the bitmap.
finally, release the clonedisplay and the font.

tried to create a cloned display use"IDISPLAY_Clone()" and use IDISPLAY_SetDestination to related the bitmap and the clonedisplay, and save the old bitmap of clonedisplay.
then do what you want to do use the bitmap.
finally, release the clonedisplay and the font.

Hi,
I am trying to crease font size for some device. Its not drawing the text when we use Ifont_DrawText. Can Some one help me.
boolean Font_DrawText(IShell *pIShell, IDisplay *pIDisplay , AECHAR* pasTextBuf, AEERect rRect, uint32 dwFlags)
{
IBitmap *pBitmap = NULL;
IBitmap *pSysBitmap = NULL;
IFont *pIFont = NULL;
IDisplay *NewpIDisplay = NULL;
int iret = 0;
if(!pIShell || !pIDisplay)
return FALSE;
//create font
ISHELL_CreateInstance(pIShell, AEECLSID_FONT_BASIC12B, (void**)( &pIFont ));
if(!pIFont)
return FALSE;
IDISPLAY_Clone(pIDisplay, &NewpIDisplay);
//create bitmap
IDISPLAY_GetDeviceBitmap(pIDisplay, &pSysBitmap);
IBITMAP_CreateCompatibleBitmap(pSysBitmap, &pBitmap, 440, 217);
IDISPLAY_SetDestination(NewpIDisplay, pBitmap);
IDISPLAY_SetFont(NewpIDisplay, AEE_FONT_BOLD, pIFont);
//draw text
iret = IFONT_DrawText(pIFont,
pBitmap,
rRect.x,
rRect.y,
pasTextBuf,
ASZ_LEN(pasTextBuf),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,0,0)),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,255,0)),
&rRect,
IDF_TEXT_TRANSPARENT);
IDISPLAY_BitBlt(NewpIDisplay,rRect.x, rRect.y, rRect.dx, rRect.dy, pBitmap, rRect.x, rRect.y, AEE_RO_COPY);
IDISPLAY_Update(NewpIDisplay);
IDISPLAY_SetDestination(pIDisplay, pSysBitmap);
if(pIFont)
{
IFONT_Release(pIFont);
pIFont = NULL;
}
if(pSysBitmap)
{
IBITMAP_Release(pSysBitmap);
pSysBitmap = NULL;
}
if(pBitmap)
{
IBITMAP_Release(pBitmap);
pBitmap = NULL;
}
return TRUE;

Thanks,
Naresh

Hi,
I am trying to crease font size for some device. Its not drawing the text when we use Ifont_DrawText. Can Some one help me.
boolean Font_DrawText(IShell *pIShell, IDisplay *pIDisplay , AECHAR* pasTextBuf, AEERect rRect, uint32 dwFlags)
{
IBitmap *pBitmap = NULL;
IBitmap *pSysBitmap = NULL;
IFont *pIFont = NULL;
IDisplay *NewpIDisplay = NULL;
int iret = 0;
if(!pIShell || !pIDisplay)
return FALSE;
//create font
ISHELL_CreateInstance(pIShell, AEECLSID_FONT_BASIC12B, (void**)( &pIFont ));
if(!pIFont)
return FALSE;
IDISPLAY_Clone(pIDisplay, &NewpIDisplay);
//create bitmap
IDISPLAY_GetDeviceBitmap(pIDisplay, &pSysBitmap);
IBITMAP_CreateCompatibleBitmap(pSysBitmap, &pBitmap, 440, 217);
IDISPLAY_SetDestination(NewpIDisplay, pBitmap);
IDISPLAY_SetFont(NewpIDisplay, AEE_FONT_BOLD, pIFont);
//draw text
iret = IFONT_DrawText(pIFont,
pBitmap,
rRect.x,
rRect.y,
pasTextBuf,
ASZ_LEN(pasTextBuf),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,0,0)),
IBITMAP_RGBToNative(pBitmap, MAKE_RGB(255,255,0)),
&rRect,
IDF_TEXT_TRANSPARENT);
IDISPLAY_BitBlt(NewpIDisplay,rRect.x, rRect.y, rRect.dx, rRect.dy, pBitmap, rRect.x, rRect.y, AEE_RO_COPY);
IDISPLAY_Update(NewpIDisplay);
IDISPLAY_SetDestination(pIDisplay, pSysBitmap);
if(pIFont)
{
IFONT_Release(pIFont);
pIFont = NULL;
}
if(pSysBitmap)
{
IBITMAP_Release(pSysBitmap);
pSysBitmap = NULL;
}
if(pBitmap)
{
IBITMAP_Release(pBitmap);
pBitmap = NULL;
}
return TRUE;

Thanks,
Naresh