Results 1 to 2 of 2
Thread: Graphics problem?
- 05-28-2011, 08:35 PM #1
Graphics problem?
So ... im trying to split an image to different parts ... everything works well except when i draw the image its black where its supposed to be transperant and white where there is supposed to be colors =P Iv no idea of what has gone wrong ... here is how i do the splitting:
and then I use the images in the array by :Java Code:public static BufferedImage[][] splitImage(BufferedImage img, int cols, int rows) { int w = img.getWidth()/cols; GUI.getGUI().centerPanel.setSpiteWidth(w); int h = img.getHeight()/rows; GUI.getGUI().centerPanel.setSpiteHeight(h); int num = 0; BufferedImage imgs[][] = new BufferedImage[rows][cols]; for(int y = 0; y < rows; y++) { for(int x = 0; x < cols; x++) { imgs[y][x] = new BufferedImage(w, h, img.getType()); Graphics2D g2d = imgs[y][x].createGraphics(); g2d.drawImage(img, 0, 0, w, h, w*x, h*y, w*x+w, h*y+h, null); g2d.dispose(); System.out.println(num++); } } System.out.println("Done"); return imgs; }
any ideas? =P thanks alotJava Code:public void paintComponent(Graphics g){ super.paintComponent(g); Graphics2D g2d = (Graphics2D)g; g2d.drawImage(pics[currentRow][currentCol], spiteX, spiteY, spiteW, spiteH, null); }
- 05-28-2011, 09:06 PM #2
Similar Threads
-
KeyListener Graphics Problem
By Makesfolkslose in forum New To JavaReplies: 2Last Post: 05-26-2011, 04:07 AM -
Problem in Graphics
By justbeller in forum Java 2DReplies: 1Last Post: 04-03-2011, 12:39 PM -
Graphics problem
By luke24 in forum New To JavaReplies: 7Last Post: 02-19-2011, 08:19 PM -
problem with jframe&jmenu&graphics
By beni.vd in forum AWT / SwingReplies: 1Last Post: 12-31-2010, 07:07 PM -
i am having a problem with creating graphics
By umpire43055 in forum AWT / SwingReplies: 3Last Post: 08-07-2009, 05:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks