You Are Here:

Community: Developer Discussion Boards

#1 Old show image on the form from memory - 2007-08-27, 19:23

Join Date: Jun 2007
Posts: 10
aaapigfly
Offline
Registered User
Hello everyone, I am trying to show a image form the mobile memory on the form, but it does not work ,please help me to see what is the problem.
thanks
public class Slidelet extends MIDlet
{
static Slidelet instance;
SlideEngine engine = null;
InputStream is = null;
byte[] slide;
Image img = null;
private Image image1=null;
private static final int CHUNK_SIZE= 1024;
private Image currentImage = null;
Image photo = null;

public Slidelet()
{
instance = this;
}
public void startApp()
{
engine = new SlideEngine( Display.getDisplay(this ) );
Form f1 = new Form( "Slide 1");
f1.append( "This is slide number 1" );
photo=displayImage();
f1.append(new ImageItem("", photo, ImageItem.LAYOUT_TOP, null));
Form f2 = new Form( "Slide 2");
f2.append( "This is slide number 2" );
Form f3 = new Form( "Slide 3");
f3.append( "This is slide number 3" );
engine.addSlide( f1, 2000 );
engine.addSlide( f2, 2000 );
engine.addSlide( f3, 2000 );
engine.startShow();
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public static void quitApp()
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
public Image displayImage()
{
try
{
FileConnection fileConn =
(FileConnection)Connector.open("file:///root1/1.png");
InputStream fis = fileConn.openInputStream();
long overallSize = fileConn.fileSize();
int length = 0;
byte[] imageData = new byte[0];
while (length < overallSize)
{
byte[] data = new byte[CHUNK_SIZE];
int readAmount = fis.read(data, 0, CHUNK_SIZE);
byte[] newImageData = new byte[imageData.length + CHUNK_SIZE];
System.arraycopy(imageData, 0, newImageData, 0, length);
System.arraycopy(data, 0, newImageData, length, readAmount);
imageData = newImageData;
length += readAmount;
}
fis.close();
fileConn.close();
if (length > 0)
{
currentImage = Image.createImage(imageData, 0, length);
}
}
catch (Exception e)
{ }
return currentImage;
}
}






public class SlideEngine
{
Display display;

Vector sequence; // the vector hold the sequence of slides and time

Thread thread;
Timer timer;

/**
* Constructor.
* take Display object as initialize parameters
* @param d
*/
public SlideEngine( Display d )
{
display = d;
sequence = new Vector();
}

/**
* Add a slide to this engine.
* @param slide the slide
* @param t the time duration (in ms) this slide is shown on sreen
*/
public void addSlide( Displayable slide, int t )
{
sequence.addElement( slide );
sequence.addElement( new Integer(t) );
}

/**
* Start the slide show.
* This create a new thread (Timer thread) and display the sequence
*/
public void startShow()
{
timer = new Timer();
thread = new Thread( timer );
thread.start();
}

/**
* End the show.
*/
public void endShow()
{
timer.done = true;
}

/**
* This timer class execute the sequence.
*/
class Timer implements Runnable
{
int time;
boolean done;

public void run()
{
done = false;
int cur = 0; // index to sequence


while ( !done && cur < sequence.size() )
{
Object o = sequence.elementAt( cur );
System.out.println("sequence: "+o);
if ( o instanceof Displayable )
{
// if the sequence element is a Displayable, then show it on screen
Displayable d = (Displayable)o;
display.setCurrent( d );
} else if ( o instanceof Integer )
{
// if the sequence is a Integer, then pause for the duration of this number
time = ((Integer)o).intValue();
try
{
Thread.sleep( time );
} catch (Exception e)
{
}

}
// advance to next sequence element
cur++;
}
} // end of class
}


}
Reply With Quote

#2 Old Re: show image on the form from memory - 2007-08-27, 19:43

Join Date: Aug 2007
Posts: 14
ronanocie
Offline
Registered User
What is the problem exactly?

I would suggest open an image, adding it to a Vector, then painting it onto a Canvas, and not use Forms at all. Use a second vector for the image titles. Then, have 2 Image objects to display on the Canvas. You could then animate (slide) the images on and off screen. It is more work, but the result is better I think.
Reply With Quote

#3 Old Re: show image on the form from memory - 2007-08-27, 21:15

Join Date: Jun 2007
Posts: 10
aaapigfly
Offline
Registered User
the question is how to show image from the phone memory on the form......
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
image doesnt show RamiX Browsing and Mark-ups 2 2007-08-16 08:20
how to show image/text info on the top of Form aplyhj Symbian User Interface 0 2007-07-24 12:05
Is MIDP2.0 over Symbian OS slow? epolitakis Mobile Java Games 7 2007-03-16 10:32
How to show a form... jhiey Symbian User Interface 1 2005-05-24 09:13
image show on view neerajsoni Symbian User Interface 0 2005-01-10 13:52

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ