Here you can find the source of nrChannels(BufferedImage img)
static public int nrChannels(BufferedImage img)
//package com.java2s; /*// w ww . j a v a 2 s. c o m * Copyright 2013, Morten Nobel-Joergensen * * License: The BSD 3-Clause License * http://opensource.org/licenses/BSD-3-Clause */ import java.awt.image.BufferedImage; public class Main { static public int nrChannels(BufferedImage img) { switch (img.getType()) { case BufferedImage.TYPE_3BYTE_BGR: return 3; case BufferedImage.TYPE_4BYTE_ABGR: return 4; case BufferedImage.TYPE_BYTE_GRAY: return 1; case BufferedImage.TYPE_INT_BGR: return 3; case BufferedImage.TYPE_INT_ARGB: return 4; case BufferedImage.TYPE_INT_RGB: return 3; case BufferedImage.TYPE_CUSTOM: return 4; case BufferedImage.TYPE_4BYTE_ABGR_PRE: return 4; case BufferedImage.TYPE_INT_ARGB_PRE: return 4; case BufferedImage.TYPE_USHORT_555_RGB: return 3; case BufferedImage.TYPE_USHORT_565_RGB: return 3; case BufferedImage.TYPE_USHORT_GRAY: return 1; } return 0; } }