@Test
public void testMakeColorTransparent() throws IllegalStateException, FileNotFoundException, IOException {

    assertTrue("Assertions should be enabled.", ImageWorker.class.desiredAssertionStatus());
    ImageWorker worker = new ImageWorker(sstImage);
    
    assertSame(sstImage, worker.getRenderedImage());
    assertEquals(  1, worker.getNumBands());
    assertEquals( -1, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertFalse (     worker.isBinary());
    assertTrue  (     worker.isIndexed());
    assertTrue  (     worker.isColorSpaceRGB());
    assertFalse (     worker.isColorSpaceGRAYScale());
    assertFalse (     worker.isTranslucent());
    assertSame("Expected no operation.", sstImage, worker.forceIndexColorModel(false).getRenderedImage());
    assertSame("Expected no operation.", sstImage, worker.forceIndexColorModel(true ).getRenderedImage());
    assertSame("Expected no operation.", sstImage, worker.forceColorSpaceRGB()       .getRenderedImage());
    assertSame("Expected no operation.", sstImage, worker.retainFirstBand()          .getRenderedImage());
    assertSame("Expected no operation.", sstImage, worker.retainLastBand()           .getRenderedImage());
    // Following will change image, so we need to test after the above assertions.
    assertEquals(  0, worker.getMinimums()[0], 0);
    assertEquals(255, worker.getMaximums()[0], 0);
    assertNotSame(sstImage, worker.getRenderedImage());
    assertSame("Expected same databuffer, i.e. pixels should not be duplicated.",
               sstImage.getTile(0,0).getDataBuffer(),
               worker.getRenderedImage().getTile(0,0).getDataBuffer());
    assertSame(worker, worker.makeColorTransparent(Color.WHITE));
    assertEquals(255,  worker.getTransparentPixel());
    assertFalse (      worker.isTranslucent());
    assertSame("Expected same databuffer, i.e. pixels should not be duplicated.",
               sstImage.getTile(0,0).getDataBuffer(),
               worker.getRenderedImage().getTile(0,0).getDataBuffer());
    
    // INDEX TO INDEX-ALPHA
    worker=new ImageWorker(chlImage).makeColorTransparent(Color.black);
    show(worker,  "CHL01195.png");
    assertEquals(  1, worker.getNumBands());
    assertEquals( 0, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertTrue  (     worker.isIndexed());
    assertTrue  (     worker.isColorSpaceRGB());
    assertFalse (     worker.isColorSpaceGRAYScale());
    assertFalse (     worker.isTranslucent());        
    RenderedImage image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof IndexColorModel);
    IndexColorModel iColorModel=(IndexColorModel) image.getColorModel();
    int transparentColor=iColorModel.getRGB(worker.getTransparentPixel())&0x00ffffff;
    assertTrue  (     transparentColor==0);
    
    
    // INDEX TO INDEX-ALPHA
    worker=new ImageWorker(bathy).makeColorTransparent(Color.WHITE);
    show(worker,  "BATHY.png");
    assertEquals(  1, worker.getNumBands());
    assertEquals( 206, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertTrue  (     worker.isIndexed());
    assertTrue  (     worker.isColorSpaceRGB());
    assertFalse (     worker.isColorSpaceGRAYScale());
    assertFalse (     worker.isTranslucent());        
    image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof IndexColorModel);
    iColorModel=(IndexColorModel) image.getColorModel();
    transparentColor=iColorModel.getRGB(worker.getTransparentPixel())&0x00ffffff;
    assertTrue  (     transparentColor==(Color.WHITE.getRGB()&0x00ffffff));        
    
    // RGB TO RGBA
    worker=new ImageWorker(smallWorld).makeColorTransparent(new Color(11,10,50));
    show(worker,  "small_world.png");
    assertEquals(  4, worker.getNumBands());
    assertEquals( -1, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertFalse  (     worker.isIndexed());
    assertTrue  (     worker.isColorSpaceRGB());
    assertFalse (     worker.isColorSpaceGRAYScale());
    assertTrue (     worker.isTranslucent());        
    image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof ComponentColorModel);  
            
    
    // RGBA to RGBA
    worker=new ImageWorker(worldImage).makeColorTransparent(Color.white);
    show(worker,  "world.png");
    assertEquals(  4, worker.getNumBands());
    assertEquals( -1, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertFalse  (     worker.isIndexed());
    assertTrue  (     worker.isColorSpaceRGB());
    assertFalse (     worker.isColorSpaceGRAYScale());
    assertTrue (     worker.isTranslucent());        
    image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof ComponentColorModel);  
    
    
    // GRAY TO GRAY-ALPHA
    worker=new ImageWorker(gray).makeColorTransparent(Color.black);
    show(worker,  "gray.png");
    assertEquals(  2, worker.getNumBands());
    assertEquals( -1, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertFalse  (     worker.isIndexed());
    assertFalse  (     worker.isColorSpaceRGB());
    assertTrue (     worker.isColorSpaceGRAYScale());
    assertTrue (     worker.isTranslucent());        
    image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof ComponentColorModel);  
    
    // GRAY-ALPHA TO GRAY-ALPHA.
    worker=new ImageWorker(grayAlpha).makeColorTransparent(Color.black);
    show(worker,  "gray-alpha.png");  
    assertEquals(  2, worker.getNumBands());
    assertEquals( -1, worker.getTransparentPixel());
    assertTrue  (     worker.isBytes());
    assertFalse  (     worker.isIndexed());
    assertFalse  (     worker.isColorSpaceRGB());
    assertTrue (     worker.isColorSpaceGRAYScale());
    assertTrue (     worker.isTranslucent());        
    image= worker.getRenderedImage();
    assertTrue  (     image.getColorModel() instanceof ComponentColorModel);         
    
    
}