Worldwind public release 0.2.1
[worldwind-tracker.git] / gov / nasa / worldwind / formats / nitfs / Cadrg2DdsCompress.java
blob1145ffa94484fb4005445b32d87d17bdd71b2c50
1 package gov.nasa.worldwind.formats.nitfs;
3 import gov.nasa.worldwind.*;
5 import java.nio.*;
6 /*
7 Copyright (C) 2001, 2007 United States Government
8 as represented by the Administrator of the
9 National Aeronautics and Space Administration.
10 All Rights Reserved.
13 /**
14 * @author Lado Garakanidze
15 * @version $Id: Cadrg2DdsCompress Apr 23, 2007 11:00:07 AM lado
17 class Cadrg2DdsCompress extends AbstractRpf2DdsCompress
19 public DDSBlock4x4 compressDxt1Block4x4(NitfsImageBand imageBand, byte[] pixelCodes, boolean hasTransparentPixels)
21 int[] pixels565 = new int[16];
22 Color[] colors565 = new Color[16];
23 for(int i = 0; i < pixelCodes.length; i++ )
25 pixels565[i] = imageBand.lookupR5G6B5( 0x00FF & pixelCodes[i] );
26 colors565[i] = DDSConverter.getColor565( pixels565[i] );
29 int[] extremaIndices = determineExtremeColors( colors565 );
31 if(pixels565[extremaIndices[0]] < pixels565[extremaIndices[1]])
33 int t = extremaIndices[0];
34 extremaIndices[0] = extremaIndices[1];
35 extremaIndices[1] = t;
38 return new DDSBlock4x4(
39 (short) pixels565[extremaIndices[0]],
40 (short) pixels565[extremaIndices[1]],
41 (int) DDSConverter.computeBitMask(colors565, extremaIndices)