Samsung e317 bug

I have an odd issue with a Samsung e317. The app works on every other phone and I’m beginning to believe it is an actual problem with the phone. i’ve tested this on three other phones and it works fine (Samsung a620, Sanyo 8100, Nokia 3595).

This is the code in question. It draws images from within images so I can limit my file size by cramming everything into one or two images.


public void drawSubImage(Graphics g, Image src,int x,int y, int subx, int suby, int width, int height)
{
  g.setClip(x,y,width,height);
  g.drawImage(src,(x-subx),(y-suby),Graphics.TOP|Graphics.LEFT);

  // reset the clip rect so further drawing works
  g.setClip(0,0,scrx,scry);
}

The problem seems to be with the second setClip which sets the clip rect back to the full screen. I have checked scrx and scry values and they are fine.

Only the graphical elements show up after calls to drawSubImage and none of the hand drawn stuff. Subsequent calls to drawSubImage do seem to work because all the image elements on the screen are drawn, just not the line/fill elements.

This is drawn to an offscreen (mutable) image and not the screen, but I don’t see how that would matter. Especially since it works on other phones.

Anyone seen similar problems on the e317?

Thanks,
Wood

I’m convinced that the Samsung e317 (Cingular) has a bug in the Graphics.fillRect method.

I did a bunch more testing with Ofscreen bitmaps and found that fill rect will not draw outside screen size if the offscreen bitmap is larger than the screen. I found a page that describes a very similar problem with Graphics.drawLine http://jroller.org/page/wangjammer5/20040617 on earlier Samsung phones. This talks about drawLine problems and the way to fix it with fillRect, but similar in behavior.

The offscreen image is larger than the screen size by 20 pixels (my tile size) so I only have to draw into the bitmap when the screen offset is larger than 20. Then I scroll smoothly and only update on the edges when the offset is > 20.

Samsung’s developer website doesn’t describe any problems what so ever with any phone and it has message boards that have questions that have gone unanswered for months. Quite stale. Welcome the J2ME hell. Bad implementations and bad developer support.

This is not one of my required phones (yet), just the phone I carry so I’m not sure if I’m going to fix it or not. The work around I’m thinking about is to have three offscreen images, one as large as the screen and two 20 pixel wide strips, one horizontal and one vertical at the bottom and right. I’ll typically have to draw all three to update the screen and do some odd behavior to update them all when the scroll factor reachs 20.

The other workaround is funny. Since the other phones have drawLine problems and the work around is to use fillRect with a width of 1, I was thinking I could maybe use drawLine in a loop to fill in the rect. Hmmm, probably a performance pig but it would be a lot easier to implement than the three separate offscreen bitmaps. Assuming drawLine didn’t have the same problem.

Hope that helps some one out there.

Wood

Just a note on one of my work arounds. Rewriting the fillRect with drawLine calls did not fix the problem. I’m betting the same bug exists in drawLine in that you cannot draw into an offscreen image in the areas that are larger than screen size.

The only solution I see is to have three offscreen images. One will be screen size, the other two will be my tile width/height and I will draw the second two on the right and bottom. I have not yet implemented this and may or may not depending on distribution.