|
|
|
08-18-2007, 05:40 AM
|
#1
|
New Member
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
|
How to use bitmap.
Please Login to Remove!
hi all,
how to add the bitmap. give some basic code to understand.
thanks
|
Offline
|
|
08-18-2007, 10:23 PM
|
#2
|
Thumbs Must Hurt
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
|
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
|
|
08-19-2007, 10:40 PM
|
#3
|
New Member
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
|
thanks Arif,
|
Offline
|
|
08-19-2007, 11:33 PM
|
#4
|
New Member
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
|
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
|
|
08-19-2007, 11:48 PM
|
#5
|
Thumbs Must Hurt
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
|
Welcome crazystar!
actually i didn't check it before. hope, i'll get back to you very soon with your interest.
Thanks,
ARIF
|
Offline
|
|
08-20-2007, 04:14 AM
|
#6
|
New Member
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: blackberry
Posts: 14
|
thanks Arif,After u try that bitmap using gif image tell me ....
|
Offline
|
|
08-20-2007, 10:49 AM
|
#7
|
CrackBerry Addict
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
|
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
|
|
08-20-2007, 11:56 PM
|
#8
|
Thumbs Must Hurt
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
|
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
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
|
|
08-21-2007, 03:14 AM
|
#9
|
CrackBerry Addict
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
|
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
|
|
08-21-2007, 06:02 AM
|
#10
|
Thumbs Must Hurt
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
|
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
|
|
08-21-2007, 11:13 PM
|
#11
|
Thumbs Must Hurt
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
|
Hi,
Only through replacing Images (ie) moving different frames of Images only we can provide animation .
|
Offline
|
|
01-09-2008, 07:48 AM
|
#12
|
Thumbs Must Hurt
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
|
Does the BlackBerry JDE 4.2.0 have API for getting the layers of the animated gif image? What is it?
|
Offline
|
|
01-09-2008, 08:10 AM
|
#13
|
CrackBerry Addict
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
|
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
|
|
01-10-2008, 02:38 AM
|
#14
|
Thumbs Must Hurt
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
|
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
|
|
01-10-2008, 05:11 AM
|
#15
|
CrackBerry Addict
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
|
Quote:
Originally Posted by pa4o85
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
|
|
01-14-2008, 03:18 AM
|
#16
|
Thumbs Must Hurt
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
|
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
|
|
01-15-2008, 03:41 AM
|
#17
|
Thumbs Must Hurt
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
|
Hi ! Is there anybody make an animated gif image suport ? I just don't know how to display the frames!
|
Offline
|
|
02-29-2008, 09:20 AM
|
#18
|
New Member
Join Date: Feb 2008
Model: 8700
PIN: N/A
Carrier: TIM Italy
Posts: 1
|
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
|
|
02-29-2008, 10:41 AM
|
#19
|
CrackBerry Addict
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
|
Quote:
Originally Posted by Al3x2003
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
|
|
02-29-2008, 12:17 PM
|
#20
|
Thumbs Must Hurt
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Posts: 138
|
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
|
|
|
|