The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

jdk1.1 awt vectors and images

Posted by mike on October 19, 2000 at 2:20 PM

i am having a problem with my painting of images. in my app i continously
store images into a vector, hence the vector continously grows. i paint
each new image in the vector on to the bottom of the viewport of my
canvas. as each new image comes in the previous images are repainted 1
image up...creating a scrolling image animation. since i get an out of
memory error after about 200 stored images i've decided to delete the
images in the vector that i've already painted. so, i keep a max of 100
images in my vector. once i receive 100 images i delete the element at
index zero for every new image i receive. my display paints and looks just
find during the 1st 100 images, but once i receive more than 100 images
the display starts to jump and everyonce and awhile it seems as my
painting rountine get's behind and overlaps previous images. so, my
question is...does anyone have a simple scheme to paint images from a
vector one after another with the following criteria:
* max capacity of vector is 100
* after this the first element is deleted for every new element
* this should keep the vector size at 100
* and i want to be able to paint all the images one after the
other

i have one thread that
Image image;
MemoryImageSource mis;
mis = new MemoryImageSource( xs, ys, colorModel, pix, 0, xs);
image = Toolkit.getDefaultToolkit().createImage( mis );
return image;
which creates the image and then it is placed into a vector. my main
thread containg the paint routine does
for(int ii = 0; ii < viewableImages; ii++) {
if((ii) < vecData.size()) {
Image si = (Image)vecData.elementAt(ii);
// multiply ii * 10 as this is the # lines in each image
if (si != null) g.drawImage(si,0,(ii*10),this);
}
}





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us