Here you can find the source of indexToDirectColorModel(BufferedImage image)
public static BufferedImage indexToDirectColorModel(BufferedImage image)
//package com.java2s; //License from project: Apache License import java.awt.*; import java.awt.image.*; public class Main { public static BufferedImage indexToDirectColorModel(BufferedImage image) { BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY); Graphics2D g2 = result.createGraphics(); g2.drawImage(image, null, null); return result; }/*from w ww .j a v a2 s . c om*/ }