Skip to content

Made in Java using only the AWT libraries to create and manage images in the fastest possible way for the best result.

Notifications You must be signed in to change notification settings

bshred8/Speedy-AWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Speedy-AWT

Made in Java using only the AWT library to create and manage images in the fastest possible way for the best result.
SpeedyAWT does not (yet) handle window creation or management. As of now, it is important that you create your own window to render images to.

Purpose

Speedy AWT, or "spa" for short, is nothing more than a wrapper for the AWT BufferedImage and VolatileImage. It creates an image created and rendered on the CPU by default, and accelerates it per the user's request.

Along with accelerated images, it has access to the basic graphical display settings via the Graphics* classes, interfaced in DisplaySettings.

Usage

SoftwareImage

The SoftwareImage constructor can create a new, blank image with a specified width, height, and alpha channel; or it may take a String parameter for the image you would like to load. Examples:
SoftwareImage sImg = new SoftwareImage(width, height, createWithAlpha);
SoftwareImage sImg = new SoftwareImage("C:/path/to/image/test.jpg");

The image may be located anywhere, and the image type may be different than .jpg, but it is not guaranteed to work. Images are loaded via ImageIO. File extension is required.


Because SoftwareImage is a wrapper for the BufferedImage class, it has many similar functions. Rather than setRGB(x, y, color) in BufferedImage, it uses direct access to pixel data and edits it quicker. That function is setPixel(x, y, color).
And, just as many other programs, if you may set it you may get it. getPixel(x, y) returns the int color value of the pixel at (x, y).
The clear(color) method takes one integer value and sets all of the data in the pixels array to that number. Essentially, it clears the entire screen to that color.
Other than more getters, this class has one more major functionality and that is its acceleration.
setAccelPriority(floatVal) takes a float value between 0.0f and 1.0f to determine how important it is to accelerate this image to use graphical memory. This is seen to the BufferedImage as a request, and not as a necessity. However, there is a way to convert this to a VolatileImage to directly put it to graphical memory. This method is accelerate(). It takes no parameters and returns a VolatileImage, which is important for HardwareImage's use as it is a wrapper for it. This creates a compatible VolatileImage from the default GraphicsConfiguration, and uses its Graphics2D to draw the BufferedImage onto it, then returns the result.

About

Made in Java using only the AWT libraries to create and manage images in the fastest possible way for the best result.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages