Use PixelGrabber class to acquire pixel data from an Image object : Image « 2D Graphics « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » 2D Graphics » Image 
16. 26. 19. Use PixelGrabber class to acquire pixel data from an Image object
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.PixelGrabber;

public class Main {
  static boolean isGreyscaleImage(PixelGrabber pg) {
    return pg.getPixels() instanceof byte[];
  }

  public static void main(String args[]) throws Exception {
    Image image = Toolkit.getDefaultToolkit().getImage("inFile.png");

    PixelGrabber grabber = new PixelGrabber(image, 00, -1, -1false);

    if (grabber.grabPixels()) {
      int width = grabber.getWidth();
      int height = grabber.getHeight();
      if (isGreyscaleImage(grabber)) {
        byte[] data = (byte[]) grabber.getPixels();
      else {
        int[] data = (int[]) grabber.getPixels();
      }
    }
  }
}
16. 26. Image
16. 26. 1. Draw ImageDraw Image
16. 26. 2. Resize an imageResize an image
16. 26. 3. Load Image and scale itLoad Image and scale it
16. 26. 4. Flush an image
16. 26. 5. Reading an Image or Icon from a File
16. 26. 6. Get the dimensions of the image; these will be non-negative
16. 26. 7. Draw an Icon object
16. 26. 8. Scaling a Drawn Image
16. 26. 9. Shearing a Drawn Image
16. 26. 10. Rotating a Drawn Image
16. 26. 11. Translating a Drawn Image
16. 26. 12. Creates PNG images of the specified color that fade from fully opaque to fully transparent
16. 26. 13. Determining If an Image Has Transparent Pixels
16. 26. 14. Getting the Color Model of an Image
16. 26. 15. Filtering the RGB Values in an Image
16. 26. 16. Flip an image
16. 26. 17. Blur our image: Blur means an unfocused image
16. 26. 18. A reflected image: effect makes an illusion as if the image was reflected in water
16. 26. 19. Use PixelGrabber class to acquire pixel data from an Image object
16. 26. 20. Calculation of the mean value of an image
16. 26. 21. This filter removes all but the red values in an image
16. 26. 22. Using mediatracker to pre-load images
16. 26. 23. Create a grayscale image with Java 2D tools
16. 26. 24. Shrinking an image by skipping pixels
16. 26. 25. Get average of a set of images
16. 26. 26. Enlarging an image by pixel replication
16. 26. 27. A 3x3 kernel that blurs an image.
16. 26. 28. A 3x3 kernel that sharpens an image.
16. 26. 29. A 3x3 kernel that embosses an image.
16. 26. 30. Brighten the image by 30%
16. 26. 31. Darken the image by 10%
16. 26. 32. Create a filter that can modify any of the RGB pixel values in an image.
16. 26. 33. Gray scale image operation
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.