Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does fastbitmap.setGray affects this.bufferedImage #68

Open
xyloww opened this issue Aug 29, 2022 · 0 comments
Open

How does fastbitmap.setGray affects this.bufferedImage #68

xyloww opened this issue Aug 29, 2022 · 0 comments

Comments

@xyloww
Copy link

xyloww commented Aug 29, 2022

Hello Sir,
In Catalano.Imaging.Filters, most methods alter
pixelsGray[xstrideX+ystrideY] = (byte) value using FastBitmap.setGray method.
How does pixelsGRAY affects this.bufferedImage in FastBitmap.toIcon/FastBitmap.saveAsJPG?

Also, I am having difficulties displaying images with DataBufferUShort after altering their FBM.pixelsGray[], may I ask if you have any advice to display/save the altered images?

Currently, Ive tried altering FastBitmap.java as follow
private void refresh() {
this.raster = getRaster();

	if (isGrayscale()){
		if (raster.getDataBuffer() instanceof DataBufferByte){
		    pixelsGRAY = ((DataBufferByte) raster.getDataBuffer().getDat
		    a();
		    }
	 else if (raster.getDataBuffer() instanceof DataBufferUShort){
		    pixelData = ((DataBufferUShort) raster.getDataBuffer().getDat
		    a();
		    ByteBuffer byteBuffer = ByteBuffer.allocate(pixelData.length*2);
		    byteBuffer.asShortBuffer().put(ShortBuffer.wrap(pixelData));
		    pixelsGray = byteBuffer.array();
		    
		    }
		}

}

The values in pixelsGray became negative when using invert(), however the this.bufferedImage remains the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant