I'm trying to port an application from J2ME to the Blackberry API. I tried to use pushRegion to replace setClip from J2ME but it seems that these two methods behave different. I have an image with 7 buttons, one on top of another, each of them having a fixed height of 13 pixels, and the only different thing is their collor, each one is lighter than the previous one. I want to set the clip to draw a certain button, but the way that I use pushRegion is not correct and only a small piece is drawn sometimes, sometimes nothing is drawn. If I make pushRegion for the whole screen than all the image is drawn. Here is my code:
graphics.pushRegion(new XYRect(0, positionY, screenWidth, buttonHeight));
graphics.drawBitmap((screenWidth - buttonImage.getWidth()) / 2, positionY - buttonFrame[i] * buttonHeight, buttonImage.getWidth(), buttonImage.getHeight(), buttonImage, 0, 0);
Should I use pushContext instead of pushRegion?
And one more problem: after several drawings ( I make the drawing in a for loop) I get "out of memory" error on the emulator, I suppose it's because of the pushRegion and popContext because I don't create other objects.