BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-18-2007, 05:40 AM   #1
crazystar
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
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, 10:23 PM   #2
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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, 10:40 PM   #3
crazystar
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Default

thanks Arif,
Offline  
Old 08-19-2007, 11:33 PM   #4
crazystar
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
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-19-2007, 11:48 PM   #5
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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, 04:14 AM   #6
crazystar
New Member
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
Default

thanks Arif,After u try that bitmap using gif image tell me ....
Offline  
Old 08-20-2007, 10:49 AM   #7
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
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-20-2007, 11:56 PM   #8
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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, 03:14 AM   #9
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
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 03:03 AM..
Offline  
Old 08-21-2007, 06:02 AM   #10
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Default

Thanks jfisher!

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


ARIF

Last edited by arifzaman; 08-21-2007 at 06:04 AM..
Offline  
Old 08-21-2007, 11:13 PM   #11
Rose
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
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
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
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
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
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
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
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
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
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
Al3x2003
New Member
 
Join Date: Feb 2008
Model: 8700
PIN: N/A
Carrier: TIM Italy
Posts: 1
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
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
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
CELITE
Thumbs Must Hurt
 
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Posts: 138
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



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16) picture

Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16)

$189.99



VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250 picture

VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250

$79.99



HSS 12pcs Valve Seat & Face Cutter 45dec 30dec 20dec for Vintage Car, Bikes ,Jee picture

HSS 12pcs Valve Seat & Face Cutter 45dec 30dec 20dec for Vintage Car, Bikes ,Jee

$235.94



Niedermaier vintage Mannequins Visual Display Props Dec. 1991 Catalogue picture

Niedermaier vintage Mannequins Visual Display Props Dec. 1991 Catalogue

$141.00



Sketchy Chics - June 2021 - December 2022. Vintage Collection Art picture

Sketchy Chics - June 2021 - December 2022. Vintage Collection Art

$22.50



Adec Vintage Adjusting Dentist Doctor Medical Stool Rolling Swivel Chair picture

Adec Vintage Adjusting Dentist Doctor Medical Stool Rolling Swivel Chair

$199.99







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