FileDocCategorySizeDatePackage
FormatConversionUtils.javaAPI DocphoneME MR2 API (J2ME)3460Wed May 02 16:47:10 BST 2007com.sun.mmedia

FormatConversionUtils

public final class FormatConversionUtils extends Object
Utility class that provides various array conversion

Fields Summary
Constructors Summary
Methods Summary
public static int[]byteArrayToIntArray(byte[] bytes)
Converts image byte[] xRGB array (4 bytes per pixel) to int[] array (32-bit per pixel), int<->byte[4] conversion is platform specific !

param
bytes byte array to convert
return
same array but converted to int[] (in big-endian format)

        if (bytes == null) return null;
        
	int[] ints = new int[bytes.length / 4];

	int intcount, bytecount;
	for (intcount = 0, bytecount = 0; bytecount < bytes.length; ) {
	    ints[intcount] = 
		(( ((int)(bytes[bytecount + 0])) << 24) & 0xFF000000) |  //A
		(( ((int)(bytes[bytecount + 1])) << 16) & 0x00FF0000) |  //R
		(( ((int)(bytes[bytecount + 2])) <<  8) & 0x0000FF00) |  //G
		(( ((int)(bytes[bytecount + 3]))      ) & 0x000000FF);   //B

	    intcount++;
	    bytecount+=4;

	}
	return ints;
    
public static byte[]intArrayToByteArray(int[] ints)
Converts image int[] array (32-bit per pixel) to byte[] xRGB array (4 bytes per pixel) int<->byte[4] conversion is platform specific !

param
ints integer array to convert
return
same array but converted to byte[] (in big-endian format)

        if (ints == null) return null;
        
	byte[] bytes = new byte[ints.length * 4];

	int intcount, bytecount;
	for (intcount = 0, bytecount = 0; intcount < ints.length; ) {
            bytes[bytecount++] = (byte)((ints[intcount] & 0xFF000000) >> 24);
            bytes[bytecount++] = (byte)((ints[intcount] & 0x00FF0000) >> 16);
            bytes[bytecount++] = (byte)((ints[intcount] & 0x0000FF00) >>  8);
            bytes[bytecount++] = (byte)((ints[intcount] & 0x000000FF)      );
	    intcount++;
	}
	return bytes;
    
public static java.lang.String[]stringArrayCopy(java.lang.String[] array)
Creates a copy of a string array. Primary usage of this method is to create copies of preset, parameter, metadata and other arrays, returned to user.

param
array String array to copy
return
copy of array

        if (array == null) return null;
        
        String[] copy = new String[array.length];
        System.arraycopy(array, 0, copy, 0, array.length);
        return copy;