Question: This is to be programmed in Java. Write a library of static methods RawPicture with read() and write() methods for saving and reading pictures from

This is to be programmed in Java.

Write a library of static methods RawPicture with read() and write() methods for saving and reading pictures from a file. The write method takes a Picture and the name of a file as arguments and writes the picture to the specified file, using the following format: if the picture is w-by-h,write w,then h, then w * h triples of integers representing the pixel color values,in row major order. The read() method takes the name of a picture file as an argument and returns a picture,which it creates by reading a picture from the specified file, in the format described. Note: Be aware that this will use up much more disk space than necessary-- the standard formats compress this information so that it will not take up so much space.

This is the original HW problem but I must meet the following criteria instead:

Do not write a library of static methods, but an instantiable Java class RawPicture. That is, each RawPicture should be an object that contains all its data in private fields. You will need members/fields/variables for:

Height.

Width.

All the pixel values, each of which is a Color triple. Use the java.awt.Color to represent each.

File name it was read from, if any.

File name it would be written to by the write() method.

Picture, for when you create a RawPicture from a Picture.

BifferedImage, for when you create a RawPicture from a file read into a BufferedImage (see below).

Use the IPJ Picture.java library to read in a GIF, JPG or PNG image from a file, and then the get() method to get the pixel values.

Your class should have four constructors:

A default constructor that creates an empty RawPicture. Afterwards it can be filled in with read() as specified below.

A constructor that takes a filename of a GIF, JPG or PNG image. Use the corresponding Picture constructor to read from file.

A constructor that takes a Picture. This is equivalent with the previous, but skips the reading from a file. You assume that the Picture has been initialized already.

A constructor that takes a filename of a GIF, JPG or PNG image, but does not use the Picture constructor directly. You should study the Picture(String filename) constructor for how a File is open and the data read into an image of the classes javax.imageio.ImageIO (Links to an external site.)Links to an external site. and java.awt.image.BufferedImage (Links to an external site.)Links to an external site. are used to read. Use this code to read the image. After performing this, you should still populate your own internal representation, contained in the first three fields specified above.

A constructor that takes a filename of a RAW (see below) image and reads it in. Note: We will talk about file I/O and show how it is done.

The read() and write() methods should not work with Picture objects.

read() should read a RawPicture from a RAW file (see below). Note: We will talk about file I/O and show how it is done.

write() should write from a RawPicture to a file. Use the extension RAW.

Here is the code I have so far help me complete the TODO:

To clarify please finish the read,write,and the main.If you need links please ask.

This is to be programmed in Java. Write a library of staticmethods RawPicture with read() and write() methods for saving and reading pictures

public RawPicture(String filename) //initialize relevant private members 43 fromF 1 le name fl le name; = 45 46 47 48 49 50 51 52 53 54 /I TODO Iif image is GIF, JPG, or PNG I... populate pixels from BufferedImage read from a File // else I.. populate pixels with a call to RawPicture::read() public void write(String toFilename) /I TODO 56 57 58 59 60 public void read (String fromFilename) f /I TODO public static void main(String] args) /I TODO 62 63 public RawPicture(String filename) //initialize relevant private members 43 fromF 1 le name fl le name; = 45 46 47 48 49 50 51 52 53 54 /I TODO Iif image is GIF, JPG, or PNG I... populate pixels from BufferedImage read from a File // else I.. populate pixels with a call to RawPicture::read() public void write(String toFilename) /I TODO 56 57 58 59 60 public void read (String fromFilename) f /I TODO public static void main(String] args) /I TODO 62 63

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!