The Artima Developer Community
Sponsored Link

Java Answers Forum
Java simple program help needed

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
nabeel dadabhoy

Posts: 1
Nickname: tortured
Registered: Oct, 2005

Java simple program help needed Posted: Oct 20, 2005 5:27 AM
Reply to this message Reply
Advertisement
Hi
Urgent help needed can anyone plz solve this simple program for me?????

Thanxs alot..

from the tortured soul




write a program to decode and display an image. The file
picture.txt contains numerical data that encodes an image. The first few lines
(and the last) are as follows:
174 199
63 3 55 3 6 0 50 3
63 3 53 3 4 0 3 1 1 0 50 3
63 3 52 3 2 0 2 1 1 0 3 1 1 0 50 3
…
-1
The first line contains a pair of numbers that are the image’s width and height
respectively. Each subsequent line, except the last, consists of a set of (count,
color) pairs. Each distinct color value stands for a particular pixel color within the
image. The count value specifies how many consecutive pixels of the associated
color should be plotted. So the example above specifies that the first line of the
image consists of 63 pixels of color 3, followed by a further 55 pixels of color 3,
then 6 pixels of color 0, and 50 more of color 3. The sum of the count values in
each line of the input file is equal to the width of the image. The first count on the
final line of the file is negative (out of bounds) value, indicating the end of the
image.
The PicturePlotter class defines the following constructor:
public PicturePlotter (int width, int height)
Creating a PicturePlotter object causes a window to appear on the screen, whose
drawing area matches the given dimensions. The class also defines the following
method:
public void plot(int x, int y, int count, int color)
which can be used to plot count lots of color starting at position (x, y) within the
image area. The class already defines associations between the color values in the
data file and the screen colors that they represent.
Write a program to read the contents of the file picture.txt and display the image
it represents on a PicturePlotter object. The main method outline is provided in
PictureMain.java to get you started.
When you have read and plotted the full image, send the PicturePlotter object a
repaint message
public void repaint()
to ensure the image is not broken up.

Topic: Drawing Oval hierarchy with Graphics g or Graphic2D Previous Topic   Next Topic Topic: Need Help with String Search

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use