Question
Using Slick2D to draw some art Introduction: The aim of this assignment is to review the use of arrays, objects and to use Slick2D to
Using Slick2D to draw some art
Introduction: The aim of this assignment is to review the use of arrays, objects and to use Slick2D to render some basic images. By the end of this assignment you should have: ? Reviewed Java arrays ? Made a basic class ? Filled an array with objects ? Written and used good loops ? Used Slick2D to render an image from basic data ? Reviewed basic File I/O
Programming Assignment Description: The file format PPM Per Pixel Map is very simple. It is a very large file format that stores integer data for each pixel in the image file. There is no compression of that data. The goal of this assignment is to create a modified PPM viewer. Were going to use a simpler version of the PPM that we will call a SPM Simple Pixel Map. There will be two versions that you will load from Files a greyscale version and a color version.
Specifications:
1. You will create a simple GreyScalePixel class.
Properties: x , y, greyValue
Methods: Constructors, Void Draw(Graphics), Color MakeRGB() converts the greyValue into an RGB color
This class will draw a single pixel at the coordinate stored within. Do you need getters/setters? Do you need any other methods?
2. From GreyScalePixel you will inherit and create RGBPixel. Properties: red integer between 0 255, green integer between 0 255, blue integer between 0 255...Method: Maybe a helper method to convert 0-255 into a 0.0 1.0 range, Getters/Setters for red, green, blue. They should take in an integer between 0 and 255
What if its not? Throw an exception maybe? Exception handling? Set to default max/min values?
Getter/Setter for alpha: The greyValue from GreyScalePixel can easily become an Alpha value in RGBPixel
3. Your main class will load a file specified from the user. You can do this loading logic in the init() method that Slick2D provides.
Note: you can use scanner for this and get the input from the console; dont worry about writing complex input routines into Slick2D
4. Once you have loaded the file into an appropriate array of pixel objects, use the render method to display the image through a slick2D window. File Format: First line will contain a G or C for grey or color Second line will contain two integers for number of pixel wide by high After that will be the image data. ? If it is a G-file each pixel will simply be a value between 0 (black) and 255 (white) ? If it is a C-file each pixel will be 3 integer values between 0 and 255 in order RED GREEN BlUE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started