SINHALA and J2ME

Java programming topics
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: SINHALA and J2ME

Post by Rksk » Fri Apr 02, 2010 9:45 am

if i want to modify these pngfonts, what is the suitable image editor wich lets draw images without a background ?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: SINHALA and J2ME

Post by Neo » Fri Apr 02, 2010 3:22 pm

I usually use Adobe Photoshop to draw images with a transparent background.

However there are methods to convert a font file straight to a PNG.

See How to convert a font to an image (PNG) using php

There are some software you can use as well. See following links.
http://www.lmnopc.com/bitmapfontbuilder/
http://www.angelcode.com/products/bmfont/
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: SINHALA and J2ME

Post by Rksk » Fri Apr 02, 2010 3:32 pm

I generated a font image using below AUTOIT code. but it have a back ground color. i want to remove it.
The attachment my font.png is no longer available

Code: Select all

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>


_Main()

Func _Main()
	Local $hGUI, $hWnd, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout




	_GDIPlus_Startup ()
	
	$hBitmap= @DesktopDir & "/1.jpg"
$hImage   = _GDIPlus_ImageLoadFromFile($hBitmap)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)

	$hBrush = _GDIPlus_BrushCreateSolid (0xFF00007F)
	$hFormat = _GDIPlus_StringFormatCreate ()
	$hFamily = _GDIPlus_FontFamilyCreate ("Madhura")
	$hFont = _GDIPlus_FontCreate ($hFamily, 10, 0)
	  $hPen = _GDIPlus_PenCreate ()
   

	
	Global $asc = 32
	while $asc<>256
		$tLayout = _GDIPlus_RectFCreate (($asc-32)*15, 0, 400, 300)
		_GDIPlus_GraphicsDrawStringEx ($hGraphic,Chr ($asc ) , $hFont, $tLayout, $hFormat, $hBrush)
;~ 		 _GDIPlus_GraphicsDrawLine ($hGraphic, ($asc-32)*15, 0, ($asc-32)*15, 12, $hPen)
		$asc+=1
	wend
	
	FileDelete(@DesktopDir & "/madura.png")
_GDIPlus_ImageSaveToFile($hImage, @DesktopDir & "/madura.png")

	_GDIPlus_FontDispose ($hFont)
	_GDIPlus_FontFamilyDispose ($hFamily)
	_GDIPlus_StringFormatDispose ($hFormat)
	_GDIPlus_BrushDispose ($hBrush)

	_GDIPlus_GraphicsDispose ($hGraphic)
	_GDIPlus_ShutDown ()

EndFunc  
my font.png
my font.png (6.06 KiB) Viewed 5910 times
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: SINHALA and J2ME

Post by Neo » Fri Apr 02, 2010 4:04 pm

Okay. So it uses GD. I'm sure you must be able to find the method to make the background transparent.

The main problem I see is, you load a JPG as as your canvas. You don't want to do that.

It must be possible for you to find following functions from GD library and need to call them in order.

img = imagecreate (width, height);
background = ImageColorAllocate(img, 255, 255, 255);
ImageColorTransparent(img, background);
ImageInterlace(img, false);

Try using _GDIPlus_ as a prefix to above functions. ex: _GDIPlus_imagecreate.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: SINHALA and J2ME

Post by Neo » Fri Apr 02, 2010 4:14 pm

Neo wrote:Okay. So it uses GD. I'm sure you must be able to find the method to make the background transparent.

The main problem I see is, you load a JPG as as your canvas. You don't want to do that.

It must be possible for you to find following functions from GD library and need to call them in order.

img = imagecreate (width, height);
background = ImageColorAllocate(img, 255, 255, 255);
ImageColorTransparent(img, background);
ImageInterlace(img, false);

Try using _GDIPlus_ as a prefix to above functions. ex: _GDIPlus_imagecreate.
This is not quit right. I thought it is the standard GD, not GDI.
Since this is GDI+, you can easily refer to the documentation and find a way to create an image with transparent background, then draw the fonts. Finally save it to PNG format.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: SINHALA and J2ME

Post by Rksk » Fri Apr 02, 2010 5:08 pm

Pls help me to do it
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: SINHALA and J2ME

Post by Rksk » Fri Apr 02, 2010 5:24 pm

User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: SINHALA and J2ME

Post by Neo » Fri Apr 02, 2010 5:44 pm

Great. So it's all in there.
I still think you need to start C# with Visual Studio C# Express Edition (free).
There are lots of examples, tutorials, etc... for these types of work for C#.
Honestly, I don't see any future for you with what you are using for GDI+ work.
Post Reply

Return to “Java Programming”