aspose file tools*
The moose likes Java Micro Edition and the fly likes Images + String -Byte Array.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Images + String -Byte Array.." Watch "Images + String -Byte Array.." New topic
Author

Images + String -Byte Array..

Kamlesh Ladva
Greenhorn

Joined: Sep 16, 2008
Posts: 1
Hello guys,

I am trying to read images and strings from a byte array stored on a server using j2me..The following code does work but shows only 2 images & strings instead of the required 5..It throws a null pointer exception on the g.drawimage...line...any help would be much appreciated guys..

public void showVenues(byte[] venueList)
{
listOfText = new String[5];
imageList = new Image[5];
int textLength = 0;
int imageLength = 0;
int totalLength = 0;
int offset = 0;
try
{
for (int z = 0; z< 5; z++)
{
textLength = arr2int(venueList, totalLength);
imageLength = arr2int(venueList, totalLength+4);
listOfText[z] = new String(venueList, totalLength+8, textLength, "ASCII");
imageList[z] = Image.createImage(venueList, totalLength+8+textLength, imageLength);
totalLength += textLength + imageLength + 8;
}
}
catch(Exception uex)
{
System.out.println(uex.getMessage());
}
}

public void paintVenues(Graphics g)
{
System.out.println("Painting venues");
g.setColor(0xD3D3D3);
g.fillRect(0, 0, getWidth(), getHeight());
for (int i = 0; i<= imageList.length; i++)
{
g.drawImage(imageList[i], 0, 50 * (i+1), 0);
g.setColor(0);
//g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
g.drawString(listOfText[i], 50, 55 * (i+1), 0);

}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Images + String -Byte Array..