473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Image Doublebuffering

Although I have programmed for several decades I am new to Java. I decided
to learn it to create Applets to use in web pages I make as a volunteer in
the computer club at a seniors' centre.

My current learning project is to divide a picture into rows and columns of
squares, then redisplay the picture with these squares positioned randomly
in the rows and columns.

In an applet I have stored the original picture as an image, divided it up
into the squares (each containing part of the picture), and stored the
images of each of these squares in an array of images. Since there are 48
squares I have also randomized the order of 48 numbers (0 to 47) and then
used these numbers with some simple arithmetic to create random positions
(rows and columns) for each of the squares. I wish to use these random rows
and columns to display each of the squares in the applet's display area.

When I try this, some of the squares display okay but others do not get
displayed. By putting a delay between the displaying of each square what
appears to happen is that some squares display in their random positions,
then the display area clears and then others display in their random
positions.

I have tried putting
public void update(Graphics g) {
paint(g);
}

in my program to stop the clearing but this does not work. So I am now
trying to use double buffering to display the squares at random positions in
a buffered image rather than on the screen and then, after all squares have
been drawn, transfer the buffered image to the applet display area. The
problem is that the Java book I am using seems to be outdated and all the
code examples I find on the Internet have so much in them that I cannot
(with my novice understanding of Java) extract the useful part of the code
that does the double buffering. (I also have a novice's incomplete
understanding of how paint and repaint work.)

Could anyone provide the code which will let me create a buffered image,
then draw the various picture squares to this image at their randomized
positions, and then redraw the completed image of squares to the screen
display area? (I already have the row and column positions for the picture
squares and the actual picture squares.) As a novice I also need to have
some instruction on where to put the above coding in the structure of the
applet. I currently get the original picture, divide it into squares and
determine the randomized positions in a 'public void init()' with the
squares and positions stored in arrays. Does the double buffering have to
take place in the 'public void paint(Graphics g)' area?

Thank you.

Doug van Vianen
Jul 17 '05 #1
0 2740

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Pierre Tremblay | last post by:
Hi! I am trying to display an image in my html document. The document contains the following line: <td class="Input"><img...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
6
by: QuasiChameleon | last post by:
Hi, I'm trying to create a grayscale image class that reads and writes grayscale Targa format. This works well with smaller images, but corrupts larger images and creates a "Segmentation fault...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.