You Are Here:

Community: Developer Discussion Boards

#1 Old pixel manipulation with DirectGraphics does not work on UI30/40 phone - 2003-07-04, 14:42

Join Date: May 2003
Posts: 4
bernie25
Offline
Registered User
Hi!

I have a problem with the getPixels and drawPixels Method on UI30/40 phones. These Methods do work on Serie60 emulator and Phone, but on oher phones they give an error java.lang.IllegalArgumentException
cause the format (TYPE_INT_888_RGB) is not supported.

The problem is that i have tryed all formats (like TYPE_BYTE_1_GRAY_VERTICAL) , but none of them work.

It seems to me that pixel manipulation is not supported by UI30/40. Would be nice if somebody has a solution for me, because I porting a UI40 application to UI30 and I have the problem that the smallerst font is 9p like on UI40 phones. That meens that you can have a header text, 3 lines of text and a footer text with the Button Text, and that is obviously not enough.

I don't understand why nokia has not implemented a smaller font on this phone especially when the screen size breaks the j2me recomondation from sun (minimum height = 96).

Therefore I want to write a method that draws text to a mutable image and reduce the image to half its size. If I use the mid font (11p) it gives a readable text on UI60 phones.

I know that I coud use the resizeImage method from shmoove, but it just interleaves pixels, and that produces an unreadable text.
Im afraid that i have to code my own font system and i have no Idea how to do this cause i can't use a monospace font like in most j2me games (then the benefit of a small font would be lost by the spaces between the letters).

Would be fine if somebody could help me and give me a hint or a working solution for smaller font.


thanks in advance!


my paint routine -> it reduces the whole screen size by fator 2, the former paint is done in zoomPaint(gZoom):


zoomImage = new Image[1];

zoomImage[0] = Image.createImage(width,height);



protected void paint(Graphics g) {
DirectGraphics dg = DirectUtils.getDirectGraphics(g);
int pixelBoxX1[] = new int[width];
int pixelBoxX2[] = new int[width];
int pixelBoxX3[] = new int[width/2];

int pixelR1;
int pixelG1;
int pixelB1;
int pixelR2;
int pixelG2;
int pixelB2;
int pixelR3;
int pixelG3;
int pixelB3;

int pixelR4;
int pixelG4;
int pixelB4;
int pixelR5;
int pixelG5;
int pixelB5;
int pixelR6;
int pixelG6;
int pixelB6;
int pixelR7;
int pixelG7;
int pixelB7;


Graphics gZoom = zoomImage[0].getGraphics();
DirectGraphics dgZoom = DirectUtils.getDirectGraphics(gZoom);
zoomPaint(gZoom);



// g.drawImage(scaleImage(zoomImage[0],width/2,height/2),0,0,Graphics.TOP|Graphics.LEFT);


// for (int x=0; x<width/2-1; x++) {
for (int y=0; y<height/2-1; y++) {
dgZoom.getPixels(pixelBoxX1,0,0,0,y*2,width,1,dg.TYPE_INT_888_RGB);
dgZoom.getPixels(pixelBoxX2,0,0,0,y*2+1,width,1,dg.TYPE_INT_888_RGB);



for (int x=0; x<width/2-1; x++) {
pixelB1 = 0x0000FF00 & pixelBoxX1[x*2];
pixelG1 = 0x00FF0000 & pixelBoxX1[x*2];
pixelR1 = 0xFF000000 & pixelBoxX1[x*2];

pixelB2 = 0x0000FF00 & pixelBoxX1[x*2+1];
pixelG2 = 0x00FF0000 & pixelBoxX1[x*2+1];
pixelR2 = 0xFF000000 & pixelBoxX1[x*2+1];


pixelB3 = 0x0000FF00 & ((pixelB1/2 + pixelB2/2));
pixelG3 = 0x00FF0000 & ((pixelG1/2 + pixelG2/2));
pixelR3 = 0xFF000000 & ((pixelR1/2 + pixelR2/2));



pixelB4 = 0x0000FF00 & pixelBoxX2[x*2];
pixelG4 = 0x00FF0000 & pixelBoxX2[x*2];
pixelR4 = 0xFF000000 & pixelBoxX2[x*2];

pixelB5 = 0x0000FF00 & pixelBoxX2[x*2+1];
pixelG5 = 0x00FF0000 & pixelBoxX2[x*2+1];
pixelR5 = 0xFF000000 & pixelBoxX2[x*2+1];

pixelB6 = 0x0000FF00 & ((pixelB4/2 + pixelB5/2));
pixelG6 = 0x00FF0000 & ((pixelG4/2 + pixelG5/2));
pixelR6 = 0xFF000000 & ((pixelR4/2 + pixelR5/2));

pixelB7 = 0x0000FF00 & ((pixelB6/2 + pixelB3/2));
pixelG7 = 0x00FF0000 & ((pixelG6/2 + pixelG3/2));
pixelR7 = 0xFF000000 & ((pixelR6/2 + pixelR3/2));

pixelBoxX3[x] = pixelB7 | pixelG7 | pixelR7 ;
}

//zoomPixel[0] = 0x00FF00FF;
dg.drawPixels(pixelBoxX3,false,0,0,0,y,width/2,1,0,dg.TYPE_INT_888_RGB);

}
// }



}
Reply With Quote

#2 Old 2003-07-10, 12:36

Join Date: Apr 2003
Posts: 34
Location: Russia
lizergil
Offline
Registered User
I have same problem, series 40 emulators and real phone (nokia 6800) throws IllegalArgumentException :(
It is so bad...
Only series 40 concept emulator works as well.
Dear Nokia Experts, explain please, what`s wrong???

code-------------------------------
dg = DirectUtils.getDirectGraphics(g);
int format = dg.getNativePixelFormat();
dg.getPixels(pixels, 0, 128, 0, 0, 128, 128, format);
dg.drawPixels(pixels, false, 0, 128, 0, Y, 128, 128, 0, format);


code-------------------------------
dg = DirectUtils.getDirectGraphics(g);
dg.getPixels(pixels, 0, 128, 0, 0, 128, 128, 888);
dg.drawPixels(pixels, false, 0, 128, 0, Y, 128, 128, 0, 888);

I tryed all formats, and has one result - exception :(:(:(
Reply With Quote

#3 Old Try TYPE_USHORT_4444_ARGB - 2003-07-10, 12:44

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
Guys, I am not sure that it addresses exactly your problem, but I successfully use TYPE_USHORT_4444_ARGB format in drawPixels both for Series 60 and Series 40. I din't ever had a need for getPixels
Reply With Quote

#4 Old 2003-07-10, 12:52

Join Date: Apr 2003
Posts: 34
Location: Russia
lizergil
Offline
Registered User
to doctordwarf: THANX!!
Works on emulator and on the phone 6800! :D
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