BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-17-2009, 12:36 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2009
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default pushRegion, pushContext and popContext - how do they work?

Please Login to Remove!

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:

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);

graphics.popContext();
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.
Offline  
Old 09-17-2009, 02:11 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2009
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had to use pushContext instead of pushRegion and everything is ok. But maybe someone can tell me the difference between these two methods.
Offline  
Closed Thread


Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

JOHNSON CONTROLS A350PS-1C NSFP A350PS1C
$105.0
JOHNSON CONTROLS A350PS-1C NSFP A350PS1C pictureJOHNSON CONTROLS A19ABC-4C NSFP A19ABC4C
$107.5
JOHNSON CONTROLS A19ABC-4C NSFP A19ABC4C pictureJOHNSON CONTROLS CEB-104-0 NSFP CEB1040
$409.0
JOHNSON CONTROLS CEB-104-0 NSFP CEB1040 pictureJOHNSON CONTROLS CEB-104-0 NSPP CEB1040
$375.0
JOHNSON CONTROLS CEB-104-0 NSPP CEB1040 pictureJOHNSON CONTROLS P74FA-1C NSFP P74FA1C
$65.5
JOHNSON CONTROLS P74FA-1C NSFP P74FA1C picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.