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

DC 12V Peltier Semiconductor Refrigeration Pet Air Conditioner Fridge Cooler Fan
$12.57
DC 12V Peltier Semiconductor Refrigeration Pet Air Conditioner Fridge Cooler Fan pictureFREESCALE SEMICONDUCTOR FRDM-KL25Z, KINETIS
$29.95
FREESCALE SEMICONDUCTOR FRDM-KL25Z, KINETIS pictureLM1014N National Semiconductor Motor Speed Regulator (4 Pcs) NOS IC
$5.0
LM1014N National Semiconductor Motor Speed Regulator (4 Pcs) NOS IC picture5PCS. LM1889N TV Video Modulator ICs New Old Stock National Semiconductor
$10.0
5PCS. LM1889N TV Video Modulator ICs New Old Stock National Semiconductor picture7PCS. LM1830N Fluid Detector ICs New Old Stock National Semiconductor
$10.0
7PCS. LM1830N Fluid Detector ICs New Old Stock National Semiconductor picture






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