BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-18-2007, 06:40 AM   #1 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use bitmap.

Please Login to Remove!

hi all,


how to add the bitmap. give some basic code to understand.

thanks
Offline  
Old 08-18-2007, 11:23 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi crazystar,

Add the following code in your MainScreen class.
Code:
Bitmap HELLO_LOGO = Bitmap.getBitmapResource("hello.gif");
BitmapField helloBmpField = new BitmapField(HELLO_LOGO);
add(helloBmpField);
Hope this will meet your requirements!

Cheers,
ARIF
Offline  
Old 08-19-2007, 11:40 PM   #3 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Arif,
Offline  
Old 08-20-2007, 12:33 AM   #4 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Arif, In your example gif images is loaded but if we use gif moving pictures it is not working. it is added but that motion is not in the pictures.help me
Offline  
Old 08-20-2007, 12:48 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Welcome crazystar!

actually i didn't check it before. hope, i'll get back to you very soon with your interest.

Thanks,
ARIF
Offline  
Old 08-20-2007, 05:14 AM   #6 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Arif,After u try that bitmap using gif image tell me ....
Offline  
Old 08-20-2007, 11:49 AM   #7 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

this won't be possible - the blackberry doesn't support animated gifs. the jde converts any gifs in a project to png when you compile. if you want to use an animated gif you should save the seperate layers, the simplest way to achieve the same effect is to update the bitmap displayed in a bitmap field using a timer and timertask
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 08-21-2007, 12:56 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ya, I've the same experience!

The BlackBerry devices support graphics in PNG format. Images in GIF or JPG (JPEG) format can also be added to application projects in the BlackBerry JDE. The BlackBerry JDE converts GIF or JPG images into PNG format automatically when it compiles a project. If an application accesses raw image data on the device, it retrieves PNG image data.

Quote:
Originally Posted by jfisher View Post
if you want to use an animated gif you should save the seperate layers, the simplest way to achieve the same effect is to update the bitmap displayed in a bitmap field using a timer and timertask
jfisher, A Code snippet would help.

Thanks,
ARIF
Offline  
Old 08-21-2007, 04:14 AM   #9 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

not tested it but something like this should work:

Code:
Bitmap image000 = Bitmap.getBitmapResource("image000.png");
Bitmap image001 = Bitmap.getBitmapResource("image001.png");
Bitmap image002 = Bitmap.getBitmapResource("image002.png");
Bitmap image003 = Bitmap.getBitmapResource("image003.png");
Bitmap image004 = Bitmap.getBitmapResource("image004.png");

BitmapField animationField = new BitmapField(image000);
    
Timer animationTimer = new Timer();
TimerTask animationTask;

int counter = 0;

animationTask = new TimerTask() {
	public void run() {
		if(counter == 0){
			animationField.setBitmap(image000);
		}
		if(counter == 1){
			animationField.setBitmap(image001);
		}
		if(counter == 2){
			animationField.setBitmap(image002);
		}
		if(counter == 3){
			animationField.setBitmap(image003);
		}
		if(counter == 4){
			animationField.setBitmap(image004);
			counter = -1;
		}
		counter++;
	}
};
	
animationTimer.scheduleAtFixedRate(animationTask, 1000, 1000);
	
add(animationField);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!

Last edited by jfisher : 08-22-2007 at 04:03 AM.
Offline  
Old 08-21-2007, 07:02 AM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks jfisher!

All time we need to save seperate layer for animated gif.


ARIF

Last edited by arifzaman : 08-21-2007 at 07:04 AM.
Offline  
Old 08-22-2007, 12:13 AM   #11 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Only through replacing Images (ie) moving different frames of Images only we can provide animation .
Offline  
Old 01-09-2008, 07:48 AM   #12 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does the BlackBerry JDE 4.2.0 have API for getting the layers of the animated gif image? What is it?
Offline  
Old 01-09-2008, 08:10 AM   #13 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

the JDE is not intended to manipulate gif-images. try a google with 'gif animation extract' or something along this line.

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 01-10-2008, 02:38 AM   #14 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am trying to resolve this problem using EncodedImage and its child GIFEncodedImage classes from the standard RIM library. How do you think about that?
Offline  
Old 01-10-2008, 05:11 AM   #15 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by pa4o85 View Post
I am trying to resolve this problem using EncodedImage and its child GIFEncodedImage classes from the standard RIM library. How do you think about that?
Quote:
the blackberry doesn't support animated gifs
qft
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 01-14-2008, 03:18 AM   #16 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Animated Gif Problem !

I have a class like this that pushes to the stack a new screen that is a picture (jpeg, gif or something). In the case i have an animated gif I have a problem with displaying the frames of the gif. Here is my class:

Code:
public class FullScreenBanner extends MainScreen {
  private int bannerWidth;
  private int bannerHeight;
  
  private int wFrame;
  private int hFrame;
  private int lOffset = 0;
  private int tOffset = 0;
  
  private EncodedImage encodedImage;
  private Bitmap fullScreen;
  
  private int index = 0;
  private int backgroundColor;
  /** 
   * Constructor
   * 
   * @param fullScreenBanner - byte array
   */
  public FullScreenBanner(byte[] fullScreenBanner, int color) {
    super(Manager.NO_VERTICAL_SCROLL);
    encodedImage = EncodedImage.createEncodedImage(fullScreenBanner, 0, fullScreenBanner.length);
    wFrame = bannerWidth = encodedImage.getWidth();
    hFrame = bannerHeight = encodedImage.getHeight();
    if (encodedImage.getImageType() == EncodedImage.IMAGE_TYPE_GIF) {
      getNextFrame();
    } else {
      fullScreen = Bitmap.createBitmapFromBytes(fullScreenBanner, 0, -1, 1);
    }
    this.backgroundColor = color;
  }
    
  protected void paint(Graphics g) {
    g.setBackgroundColor(backgroundColor);
    int wp = (Display.getWidth() + bannerWidth) / 2;
    int wm = (Display.getWidth() - bannerWidth) / 2;
    int hp = (Display.getHeight() + bannerHeight) / 2;
    int hm = (Display.getHeight() - bannerHeight) / 2;
    g.clear(0, 0, wp, hm);
    g.clear(wp, 0, wm, hp);
    g.clear(0, hm, wm, hp);
    g.clear(wm, hp, wp, hm);
    g.drawBitmap(wm + lOffset, hm + tOffset, wFrame, hFrame, fullScreen, 0, 0);
  }
  
  private void getNextFrame() {
    index = 0;
    TimerTask ttask = new TimerTask() {
      public void run() {
        fullScreen = encodedImage.getBitmap(index);
        GIFEncodedImage gif = (GIFEncodedImage) encodedImage;
        lOffset = gif.getScaledFrameLeft(index);
        tOffset = gif.getScaledFrameTop(index);
        wFrame = gif.getFrameWidth(index);
        hFrame = gif.getFrameHeight(index);
        if (index == (gif.getFrameCount() - 1)) {
          index = -1;
        }
        index++;
        UiApplication.getUiApplication().getActiveScreen().invalidate();
      }
    };
    GIFEncodedImage gif = (GIFEncodedImage) encodedImage;
    new Timer().scheduleAtFixedRate(ttask, gif.getFrameTransition(index) * 100, 
        gif.getFrameDelay(index) * 10);
  }
  
  protected void onFocus(int direction) {
    super.onFocus(direction);
  }
  
  protected boolean trackwheelClick(int status, int time) {
    return true;
  }
  
}
I have a timer task that gets the next frame and its offsets and a timer that execute the task. When I have a frame smaller than the gif size the frame under is gone out. I mean that every time when the area is repainting itself the old content is missing but i need it because the old frame of the gif is a part of the new one. Do u understand what i mean ?
Offline  
Old 01-15-2008, 03:41 AM   #17 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ! Is there anybody make an animated gif image suport ? I just don't know how to display the frames!
Offline  
Old 02-29-2008, 09:20 AM   #18 (permalink)
New Member
 
Join Date: Feb 2008
Model: 8700
PIN: N/A
Carrier: TIM Italy
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

HELP ME!

I want play a gif animate into my midlet for Blackberry. Exist an method to it?

An example?

Thanks to yours help!
Offline  
Old 02-29-2008, 10:41 AM   #19 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Al3x2003 View Post
HELP ME!

I want play a gif animate into my midlet for Blackberry. Exist an method to it?

An example?

Thanks to yours help!
read the thread you just posted in.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 02-29-2008, 12:17 PM   #20 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Posts: 138
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you want to create an animation in the same way as a gif, create a tiled image using the frames in your animation as the tiles. Then use the Sprite class to animate it.
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





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