public abstract static class Img.Processor<PROCESSOR extends Img.Processor<PROCESSOR,STAGE>,STAGE extends Img.ProcessorStage<STAGE,PROCESSOR>> extends Lang.Producer<BufferedImage>
Base class for image operator function which provides source width, height, ratio parameters on demand
| Modifier and Type | Field and Description |
|---|---|
protected Graphics2D |
g
The graphics
|
protected BufferedImage |
source
The source image
|
protected int |
sourceHeight
The source image height
|
protected double |
sourceRatio
The source image width/height ratio
|
protected int |
sourceWidth
The source image width
|
protected BufferedImage |
target
The target image
|
| Modifier | Constructor and Description |
|---|---|
protected |
Processor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beforeRun() |
protected Graphics2D |
cloneSource() |
protected Graphics2D |
createGraphics2D()
Create the
Graphics2D. |
protected STAGE |
createStage()
Create a builder for this processor.
|
protected STAGE |
createStage(BufferedImage source)
Create a builder for this processor.
|
protected void |
createTarget()
Create
target image using source width/height. |
protected Graphics2D |
g()
Get
Graphics2D instance. |
STAGE |
process(BufferedImage source) |
STAGE |
process(InputStream is) |
BufferedImage |
produce() |
protected abstract BufferedImage |
run() |
protected void |
setTargetSpec(int w,
int h)
Create
target image using specified width and height. |
protected void |
setTargetSpec(int w,
int h,
boolean withAlphaChannel)
Create
target image using specified width, height and alpha channel flag |
Img.Processor |
source(BufferedImage source)
Set source image.
|
getapplybreakOutprotected BufferedImage source
The source image
protected int sourceWidth
The source image width
protected int sourceHeight
The source image height
protected double sourceRatio
The source image width/height ratio
protected BufferedImage target
The target image
protected Graphics2D g
The graphics
protected final STAGE createStage()
Create a builder for this processor.
To provide better fluent coding experience, sub class can overwrite this function to provide specified builder instance instead of a general ProcessorBuilder as provided here
protected STAGE createStage(BufferedImage source)
Create a builder for this processor.
To provide better fluent coding experience, sub class can overwrite this function to provide specified builder instance instead of a general ProcessorBuilder as provided here
source - the source imagepublic BufferedImage produce()
produce in class Lang.Producer<BufferedImage>protected void beforeRun()
protected abstract BufferedImage run()
public Img.Processor source(BufferedImage source)
Set source image. This method will calculate and cache the following parameters about the source image:
source - the source imagepublic STAGE process(InputStream is)
public STAGE process(BufferedImage source)
protected Graphics2D g()
Get Graphics2D instance. If it is not created yet then call createGraphics2D() to create the instance
protected Graphics2D cloneSource()
protected Graphics2D createGraphics2D()
Create the Graphics2D. This method will trigger createTarget() method if target has not been created yet
protected void createTarget()
Create target image using source width/height. It will use source color model to check if alpha channel should be be added or not
protected void setTargetSpec(int w,
int h)
Create target image using specified width and height.
This method will use source code model it check if alpha channel should be added or not
w - the width of target imageh - the height of target imageprotected void setTargetSpec(int w,
int h,
boolean withAlphaChannel)
Create target image using specified width, height and alpha channel flag
w - the width of target imageh - the height of target imagewithAlphaChannel - whether it shall be created with alpha channelCopyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.