|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Convert a table BufferedImage
Hello, I would like to know how to convert a table with each cell contains the value of a pixel between 0 to 255 in a BufferedImage? I have tried the following code, but it does not work Code: bufedImage buf = new bufedImage(width, height, bufedImage.TYPE_BYTE_GRAY) ; buf.setRGB(0, 0, Width, height, pixels, 0, Width) ; |
#2
| |||
| |||
Re: Convert a table BufferedImage
Hello, Have you tries with setPixel void (int x, int y, int [] t) in the case of an image of gray. t contains only 1 row and one column contention the pixel value. x and y respectively indicates the line you column of pixels. I think you should try with the following, this will definitely give you an idea about it. If you need any more help regarding this topic then do post back and we will try to help you. |
#3
| |||
| |||
Re: Convert a table BufferedImage
Hello, Have a look at the following code, please see if this works for you Code: BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int c = 0; for( int i = 0; I <width; i + +) { for(int j = 0J <height; j + +){ picture.getRaster().setPixel(i, j, new int[1]{c}); } c + +; } |
#4
| |||
| |||
Re: Convert a table BufferedImage
Hello, Besides the proposed solution, what does not work exactly? Did you try to convert your picture to gray pixels in RGB pixel array before calling the method? Code: int[] colors = new int[pixels.length]; for (int i = 0 ; I <pixels.length ; I + +) { colors[i] = ((pixels[i] & 0xFF) << 16) | ((pixels[i] & 0xFF) << 8) | ((pixels[i] & 0xFF) << 0); } buffer.setRGB(0, 0, Width, height, colors, 0, Width) ; |
#5
| |||
| |||
Re: Convert a table BufferedImage
Hello, This code is going to help you, take a look at it Code: public class buffimgConverter { // default version of crbufimg static public buffimg crbufimg(Image imageIn, Component comp) { return crbufimg(imageIn, buffimg.TYPE_INT_ARGB, comp); } static public buffimg crbufimg(Image imageIn, int imageType, Component comp) { MediaTracker med = new MediaTracker(comp); med.addImage(imageIn, 0); try { med.waitForID(0); } catch (InterruptedException ie) { } buffimg buffimgo = new buffimg(imageIn .getWidth(null), imageIn.getHeight(null), imageType); Graphics g = buffimgo.getGraphics(); g.drawImage(imageIn, 0, 0, null); return buffimgo; } } |
#6
| |||
| |||
Re: Convert a table BufferedImage
Hello, I am new to the swing components in java, but you can try the following Code: javax.swing.JFrame f; // Initialized elsewhere // Create an image, and wait for it to load Image img = javax.swing.ImageIcon("myimage.gif").getImage(); // Create a BufferedImage of the same size as the Image BufferedImage buff = (BufferedImage)f.createImage(img.getWidth(f),img.getHeight(f)); Graphics2D g = buff.createGraphics(); // Get a Graphics2D object g.drawImage(img, 0, 0, f); // Draw the Image data into the BufferedImage |
![]() |
|
Tags: bufferedimage, columns, convert, fields, records, rows, table |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unable to work with table columns in opera browser when the table has wide layout | Janya | Technology & Internet | 5 | 27-08-2011 10:53 AM |
Link a Table to another Table to Drop Down In Main Table | himeshRES | Windows Software | 6 | 11-12-2010 02:01 PM |
To convert a pivot table to a flattened table in MS Excel | zeemga | Windows Software | 3 | 27-11-2010 06:48 AM |
How can I convert text data into table format? | Ram Bharose | Windows Software | 7 | 30-12-2009 02:58 PM |
Convert Excel data to HTML Table | Chalina | Software Development | 2 | 04-08-2009 11:21 PM |