• Post Reply Bookmark Topic Watch Topic
  • New Topic

image

 
cata lin
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
Does anybody know how to change the pixels of an image pixel-per-pixel ? Or how to rotate the image ? A link to a tutorial would be very appreciated.
Thank you.
Cheers,
Cata Lin.
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know a lot about GUI stuff but I THINK (hope i'm not wrong) that this would be better off in the Swing Forum ... so I'm moving it there.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect that what you are looking for will be part of the Java 2D API. Check out this link for more info on Java 2D. Good luck.
 
Ben Hodgson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The O'Reilly 'Java 2D Graphics' book contains information on this (and it's very good), as does the Sun Java 2D site - go to http://java.sun.com/products/jdk/1.2/docs/guide/2d/spec/j2d-image.fm3.html for a guide to BufferedImages and the following page for a guide to using rasters (which contain the pixel values).
To access and change pixel values, put your image into a BufferedImage and use getRGB() to find the pixel's RGB values, or setRGB() to set them.
To rotate an image, or do any kind of transformation on it:
Create an AffineTransform object and select the transformation
Create a RenderingHints object
Use these to create an AffineTransformOp object and pass your BufferedImage (or Raster) to the filter method of the AffineTransformOp object.
Hope this helps, or at least provides a start for somewhere to look for answers.
 
cata lin
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you very much to all of you who helped me with this problem
I really appreciate.
Cheers,
Cata Lin.
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you want to use a simple ImageFilter (or RGBImageFilter). The concept is that you load an image and assign a custom ImageFilter class to it. You then set a value in the filter (ie. setRotateDegree() ) through a method that you define. Then you simple redraw the image. The filter will automatically re-gernerate the altered image based on the algorithm that you implement in it's "public int filterRGB(int x, int y, int rgb)" method. It's a very effective method - I've used it for image fades, basic image processing and the like. Here are a couple of links that will get you started.
This has a rotateImage example applet: http://xputers.informatik.uni-kl.de/multimedia/javadoc/ui/drawing/manipImages.html
This is a much more detailed rotate with animation using imageFilters: http://www.kaposnet.hu/books/profiapplet/ch13.htm
When I start using this technique, it opened up a world of possiblities to me and it really quite simple. Good luck
Sean
 
Rose Runa K Jesmin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Can you please direct me with image filter in swing application? i.e. I define a color (red, green, blue) and the program should filter that color out from image?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!