10000 GitHub - aabalke33/rgb-offset: Offset an Image or color channels position.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

aabalke33/rgb-offset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

rgb-offset

Offset an Image or color channel position.

The rgbOffset package enables you to offset the X & Y position of inputted image pixels or the pixel values for individual RGB channels. This is a common effect in graphics programs like Adobe Photoshop and GIMP.

This package does not require JavaFX. It is built using the Java AWT API only.

No Offset Offset X= 256, Y= -128 Offset RGB channels Offset just Red X&Y = 32
0 256-128 03264-32 03200

Youtube Video Breakdown

Docker Image

The docker image is available here.

docker pull aabalke33/java-rgboffset

Requires "-it" and "-v" flags to make it interactable and to mount a host directory to be accessible to the container.

docker run -it -v C:\Users\User\Desktop:/tmp/files <image>
# Makes Desktop files accessible to container inside /tmp/files directory.

Usage

The offset methods take image data expressed as a BufferedImage. An example is provided below for a standard method of creating and inputting BufferedImage parameters.

Input Methods are overloaded. Allowing for method calls with channel values and without. If channel values are not inputted, it is assumed to be 0.

// Without Channel Values
BufferedImage image = rgbOffset.offset(image, xOffset, yOffset);

// With Channel Values
BufferedImage image = rgbOffset.offset(image, xOffset, yOffset, rxOffset, ryOffset, gxOffset, gyOffset, bxOffset, byOffset);

Important Considerations

  1. Position offset values are measured in pixels
  2. Has to be 8 Bit per Channel Image.

Example

import rgbOffset.offset;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {

        // Set Variable Names
        BufferedImage image = ImageIO.read(new File("input.jpg"));
        int xOffset = 100; // Moves image right 100 pixels
        int yOffset = 1000; // Moves image down 1000 pixels

        // Create Offset Image
        BufferedImage image = rgbOffset.offset(image, xOffset, yOffset);

        // Export Offset Image
        ImageIO.write(image, "jpg", new File("output.jpg"));
    }
}

Roadmap

  • Provide measurements other than pixels, perhaps a percentage of the total image size
  • Support 16bit and 24bit images

Misc Notes for Nerds

  • Original version that was not posted used ArrayLists to store color channel data. It was not faster than this implementation and used 3.3x the physical memory. Using BufferedImages is WAY better.

About

Offset an Image or color channels position.

Topics

Resources

Stars

Watchers

Forks

Languages

0