The following message was sent quite a while ago. and still no answer.
I am extremely interested to find out, if a bug repeats somewhere else (especially with Series 40 and Series 30 models).
The bug was so crucial for our application that we had to redesign the whole drawing logic with obvious lattency increase. For a Series 30 patching the bug would be simply impossible because of getting out of allowed midlet size.
As a matter of fact, setColour is ignored not only for drawing text, but for drawing lines as well.
I wish the bug to be recorded by Nokia personnel for further fix. I would also like to know is there will be a way to reflash (free of charge) Nokia 3650 ROM after the bug is fixed (BTW, are there any tools for reflashing Nokia ROM ?)
Sorry for being rude - this is really an awful bug.
Regards
Michael
---------------------------------
A BUG!!! Drawing to image graphics (3650)
The following (ready to use code) illustrates an awful bug noticed when running my 3650 device (all Nokia emulators I tried, work OK):
If you draw a text (width drawString) to an image graphics (obtained with getGraphics from an Image), the setColor command is ignored: all text is drawn in default black colour (can you guess what you will see on a black background ?).
If you noticed same problem on another (S60, S40 or S30) device, please answer this message.
Lookig forward...
Michael
---------------------------------------------
***********************************
TestGraphics.jad
-------------------------------------------------
MIDlet-1: TestGraphics, TestGraphics.png, com.palmcrust.testgraphics.TestGraphics
MIDlet-Jar-Size: 2460
MIDlet-Jar-URL: TestGraphics.jar
MIDlet-Name: Test Graphics
MIDlet-Vendor: Sun Microsystems
MIDlet-Version: 1.0
***********************************
TestGraphics.java
-------------------------------------------------
package com.palmcrust.testgraphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class TestGraphics extends MIDlet
{
TestCanvas tstCanvas;
// 'true' disables using image Graphics
static final boolean drawDirectly = false;
public TestGraphics() {
tstCanvas = null;
}
public void startApp() {
tstCanvas = new TestCanvas(this);
Display.getDisplay(this).setCurrent(tstCanvas);
}
public void pauseApp() {}
public void destroyApp(boolean unc) {}
}
class TestCanvas extends Canvas
{
private TestGraphics midlet;
Graphics testImgGraphics;
Image testImage;
Font textFont, smallFont;
int w, h, fh, fhs;
private static final String sampleString="Hello, world !";
private static final String drawTypeStringDirect="Directly to canvas";
private static final String drawTypeStringIndirect="Using image graphics";
private String drawTypeString;
TestCanvas(TestGraphics _midlet)
{
midlet = _midlet;
testImage = null;
testImgGraphics = null;
w = getWidth();
h = getHeight();
// Lookig for bold italic font
textFont = Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,
Font.SIZE_MEDIUM);
fh = textFont.getHeight();
smallFont = Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_ITALIC,
Font.SIZE_MEDIUM);
fhs = smallFont.getHeight();
if (!midlet.drawDirectly) {
testImage = Image.createImage(w, h);
testImgGraphics = testImage.getGraphics();
drawTypeString = drawTypeStringIndirect;
} else
drawTypeString = drawTypeStringDirect;
}
public void paint(Graphics g)
{
if (testImgGraphics == null)
drawSampleTextBoldItalicYellow(g);
else {
drawSampleTextBoldItalicYellow(testImgGraphics);
g.drawImage(testImage, 0, 0, Graphics.TOP | Graphics.LEFT);
}
}
private void drawSampleTextBoldItalicYellow(Graphics g)
{
g.setColor(0, 0, 128);
g.fillRect(0, 0, w, h);
g.setColor(255, 255, 0);
g.setFont(textFont);
g.drawString(sampleString, w >>> 1, (h-fh) >>> 1,
Graphics.HCENTER | Graphics.TOP);
g.setFont(smallFont);
g.setColor(0, 255, 255);
g.drawString(drawTypeString, w >>> 1, h-fhs,
Graphics.HCENTER | Graphics.TOP);
}
}

Reply With Quote

