Thursday, October 26, 2006
bitmap font creator, fnt to j2me converter and sample source code
This is a really nice tool so you can easily create bitmap fonts from a true type fonts.
Sample code and fnt to j2me converter
BMFont - bitmap font coverter official site
I have'nt tried this yet but from the comments i read, this will surely work. It also have a word wrap functionality.
btw, you may need to wait really really long if you try to convert .fnt file to j2me using the converter.
Sample code and fnt to j2me converter
BMFont - bitmap font coverter official site
I have'nt tried this yet but from the comments i read, this will surely work. It also have a word wrap functionality.
btw, you may need to wait really really long if you try to convert .fnt file to j2me using the converter.
Saturday, October 21, 2006
File naming convention in Symbian OS is case sensitive !!!
Keep in mind that file naming in Symbian OS is case sensitive. For example you have a file named "myimage.PNG". Take a look at the following code:
On your emulator, the file will be loaded since windows file naming convention is not case sensitive. But if you try to run the MIDlet on your phone, the application will immediatly close after you try to run it.
I have experienced this problem and it took me a while to solve it.
Image img = Image.createImage("myimage.png");
On your emulator, the file will be loaded since windows file naming convention is not case sensitive. But if you try to run the MIDlet on your phone, the application will immediatly close after you try to run it.
I have experienced this problem and it took me a while to solve it.
Wednesday, October 11, 2006
setFullscreen() not working on phone
Have you ever experienced a problem where your MIDlet seems to be in fullscreen mode on your emulator but on your actual device the image is only about 3/4 of your screen is used? You can check the following sites:
Link 1
Link 2
I encountered this bug when i tested my MIDlet on my Nokia 6630 phone. Not sure if this is applicable to any other models.
Link 1
Link 2
I encountered this bug when i tested my MIDlet on my Nokia 6630 phone. Not sure if this is applicable to any other models.
Saturday, October 07, 2006
Blending / Image Transparency
This article will help you create a transparent image effect. Before we start with the actual coding you need to first understand some important things. The following are the things that you need to keep in mind so that you can properly blend an image:
By the way, I'll be using my game engine framework on this one.
1. Lets declare the image that we will be using
2. Now lets load the image:
4. Lets now render the images. We will render a fully opaque copy of the image and a transparent image.
Some notice:
I could have used the Tools.setOpacity() method but since the Tools class on my framework is not yet clean i redeclared it to reduce some confusions.
If you dont understand why i'm using render(Graphics g) instead of paint(Graphics g) you can check out my article on how to use my game engine framework here
5. The output.

You can download the complete source code including the game engine used in this project here
- You must make sure that your device / system, supports alpha transparency levels. You can use the Display.numAlphaLevels() method to check the number of transparency level your device supports.
- You should understand that the pixels within a mutable image is always opaque. This means that mutable image cannot be transparent. You need to work with an immutable image if you want to alter its transparency level.
- You can use the Image.isMutable() method to check if an image is mutable or immutable.
- You can use the Image.createRGBImage() to create an immutable image from a mutable image(I'll show you how to use this in a short while).
By the way, I'll be using my game engine framework on this one.
1. Lets declare the image that we will be using
private Image img;
2. Now lets load the image:
// This loads the image that will serve as the background3. Now lets declare the function that will convert the mutable image to immutable image and change its opacity level:
img = Tools.loadImage("/img1.png");
You can use this method to set the level of transparency of the image. 0 is the transparent 255 is fully opaque. This function will also automatically convert mutable image to immutable image.private Image blend(Image img, int opacity) {
/*
Get the rgb data of the image; You can use the Image.getRGB() if you dont want to use my framework method
*/
int[] rgbdata = Tools.getRGBData(img);
for(int i=0; iint pixel = rgbdata[i];
// get the rgb data of the pixel by masking the bits using & bitwise operator
int r = ((pixel & 0x00ff0000) >> 16);
int g = ((pixel & 0x0000ff00) >> 8);
int b = ((pixel & 0x000000ff) >> 0);
// rearrange the pixel using its previous color channel values.
// we will only modify the alpha.
rgbdata[i] = (opacity << 24) + (r << 16) + (g << 8) + b;
}
return Image.createRGBImage(rgbdata, img.getWidth(), img.getHeight(), true);
}
4. Lets now render the images. We will render a fully opaque copy of the image and a transparent image.
protected void render(Graphics g) {
// clear the buffer
g.setColor(255,255,255);
g.fillRect(0,0,getWidth(),getHeight());
// render the image without transparency
g.drawImage(img, 0, 0, Tools.GRAPHICS_TOP_LEFT);
// render the transparent image
g.drawImage(blend(img, 70), 0, img.getHeight()/2, Tools.GRAPHICS_TOP_LEFT);
}
Some notice:
I could have used the Tools.setOpacity() method but since the Tools class on my framework is not yet clean i redeclared it to reduce some confusions.
If you dont understand why i'm using render(Graphics g) instead of paint(Graphics g) you can check out my article on how to use my game engine framework here
5. The output.

You can download the complete source code including the game engine used in this project here
Game engine framework updated!!
I have made some updates on my game engine framework
You can download the updated game engine framework here.
An example on how to use the game engine can be found here.
- I have revised some major parts of the engine that optimized its performance.
- Merged some classes to reduce the size of the output.
- Removed some irrelevant classes.
- The 'Tools' class is not yet clean. You can use it but it will surely change on my next update.
You can download the updated game engine framework here.
An example on how to use the game engine can be found here.