You Are Here:

Community: Developer Discussion Boards

#1 Old drawpixels in Nokia API - 2004-10-19, 15:00

Join Date: Jun 2003
Posts: 31
psm78
Offline
Registered User
Hi,
I first found out the pixels of an image and save it in the rms. Thn i take those pixels and copy it in an array. But whn i draw using those pixels the image does not come properly. there's lot of space between thm. can nyone help to get proper image using only pixels and not using image.
Reply With Quote

#2 Old 2004-10-19, 15:21

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Show us the code to save and load the pixel arrays to/from the RMS. I'm guessing something is wrong there.

shmoove
Reply With Quote

#3 Old 2004-10-20, 07:06

Join Date: Jun 2003
Posts: 31
psm78
Offline
Registered User
I get the pixels using getPixels of Nokia API.
The following is the class I use to save the pixels in a the form of a single string in the rms.

class SaveGame
{
static RecordStore myGame;
static boolean gameHaveBeenInit =false ;
static String gameData;

private SaveGame()
{
}

private static void initialize()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
byte[] b;

try
{
try
{
dos.writeUTF("A");
b = baos.toByteArray();
dos.close();
}
catch (IOException ioe)
{
System.out.println(ioe);
throw new RecordStoreException();
}

myGame.addRecord(b, 0, b.length);
}
catch (RecordStoreException rse)
{
close();
System.out.println(rse);
}
}
static void open()
{
try
{
myGame = RecordStore.openRecordStore("ABC", true);

if (gameHaveBeenInit) return;

if (myGame.getNumRecords() == 0)
{
initialize();
}
else /* Read myGame */
{
ByteArrayInputStream bais;
DataInputStream dis;
byte data[];

data = myGame.getRecord(1);

if (data != null)
{
try
{
bais = new ByteArrayInputStream(data);
dis = new DataInputStream(bais);

gameData = dis.readUTF();
dis.close();
if (gameData.equals(""))
{
gameData = "A";
saveGame(gameData);
}
}
catch (IOException ioe){}
}
}
gameHaveBeenInit = true;

}
catch (RecordStoreException rse){System.out.println(rse); }
}

static void close()
{
if (myGame != null)
{
try
{
myGame.closeRecordStore();
}
catch (RecordStoreException frse) { }
myGame = null;
}
}

static void saveGame(String gamedata)
{
ByteArrayOutputStream baos;
DataOutputStream das;
byte[] data;
try
{
try
{
baos = new ByteArrayOutputStream();
das = new DataOutputStream(baos);

das.writeUTF(gamedata);
data = baos.toByteArray();
das.close();
}
catch (IOException ioe)
{
throw new RecordStoreException();
}

if (myGame == null)
{
open();
myGame.setRecord(1, data, 0, data.length);
close();
}
else
{
myGame.setRecord(1, data, 0, data.length);
}
}
catch (RecordStoreException rse){}

gameData = gamedata;
}


static String getGameData()
{
if (!gameHaveBeenInit)
{
open();
close();
}
return gameData;
}
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ