ToDoubleArray() public method

Retrieves value converted to array of double values.

If value is array of double values then it retrieved unaltered.

If value is array of bytes then each 8 bytes are converted to double and added to resulting array. If value contains amount of bytes that can't be divided by 8 without remainder, then null is returned.

If value is array of float values then each element of field value gets converted to double and added to resulting array.

If value is of any other type then null is returned.

public ToDoubleArray ( ) : double[]
return double[]
Ejemplo n.º 1
0
        private bool prettyPrintField(Stream fd, TiffTag tag, int value_count, object raw_data)
        {
            FieldValue value = new FieldValue(raw_data);

            short[]  sdata = value.ToShortArray();
            float[]  fdata = value.ToFloatArray();
            double[] ddata = value.ToDoubleArray();

            switch (tag)
            {
            case TiffTag.INKSET:
                if (sdata != null)
                {
                    fprintf(fd, "  Ink Set: ");
                    switch ((InkSet)sdata[0])
                    {
                    case InkSet.CMYK:
                        fprintf(fd, "CMYK\n");
                        break;

                    default:
                        fprintf(fd, "{0} (0x{1:x})\n", sdata[0], sdata[0]);
                        break;
                    }
                    return(true);
                }
                return(false);

            case TiffTag.DOTRANGE:
                if (sdata != null)
                {
                    fprintf(fd, "  Dot Range: {0}-{1}\n", sdata[0], sdata[1]);
                    return(true);
                }
                return(false);

            case TiffTag.WHITEPOINT:
                if (fdata != null)
                {
                    fprintf(fd, "  White Point: {0:G}-{1:G}\n", fdata[0], fdata[1]);
                    return(true);
                }
                return(false);

            case TiffTag.REFERENCEBLACKWHITE:
                if (fdata != null)
                {
                    fprintf(fd, "  Reference Black/White:\n");
                    for (short i = 0; i < 3; i++)
                    {
                        fprintf(fd, "    {0,2:D}: {1,5:G} {2,5:G}\n", i, fdata[2 * i + 0], fdata[2 * i + 1]);
                    }
                    return(true);
                }
                return(false);

            case TiffTag.XMLPACKET:
                string s = raw_data as string;
                if (s != null)
                {
                    fprintf(fd, "  XMLPacket (XMP Metadata):\n");
                    fprintf(fd, s.Substring(0, value_count));
                    fprintf(fd, "\n");
                    return(true);
                }
                return(false);

            case TiffTag.RICHTIFFIPTC:
                // XXX: for some weird reason RichTIFFIPTC tag defined
                // as array of LONG values.
                fprintf(fd, "  RichTIFFIPTC Data: <present>, {0} bytes\n", value_count * 4);
                return(true);

            case TiffTag.PHOTOSHOP:
                fprintf(fd, "  Photoshop Data: <present>, {0} bytes\n", value_count);
                return(true);

            case TiffTag.ICCPROFILE:
                fprintf(fd, "  ICC Profile: <present>, {0} bytes\n", value_count);
                return(true);

            case TiffTag.STONITS:
                if (ddata != null)
                {
                    fprintf(fd, "  Sample to Nits conversion factor: {0:e4}\n", ddata[0]);
                    return(true);
                }
                return(false);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private bool prettyPrintField(Stream fd, TiffTag tag, int value_count, object raw_data)
        {
            FieldValue value = new FieldValue(raw_data);
            short[] sdata = value.ToShortArray();
            float[] fdata = value.ToFloatArray();
            double[] ddata = value.ToDoubleArray();

            switch (tag)
            {
                case TiffTag.INKSET:
                    if (sdata != null)
                    {
                        fprintf(fd, "  Ink Set: ");
                        switch ((InkSet)sdata[0])
                        {
                            case InkSet.CMYK:
                                fprintf(fd, "CMYK\n");
                                break;

                            default:
                                fprintf(fd, "{0} (0x{1:x})\n", sdata[0], sdata[0]);
                                break;
                        }
                        return true;
                    }
                    return false;

                case TiffTag.DOTRANGE:
                    if (sdata != null)
                    {
                        fprintf(fd, "  Dot Range: {0}-{1}\n", sdata[0], sdata[1]);
                        return true;
                    }
                    return false;

                case TiffTag.WHITEPOINT:
                    if (fdata != null)
                    {
                        fprintf(fd, "  White Point: {0:G}-{1:G}\n", fdata[0], fdata[1]);
                        return true;
                    }
                    return false;

                case TiffTag.REFERENCEBLACKWHITE:
                    if (fdata != null)
                    {
                        fprintf(fd, "  Reference Black/White:\n");
                        for (short i = 0; i < 3; i++)
                            fprintf(fd, "    {0,2:D}: {1,5:G} {2,5:G}\n", i, fdata[2 * i + 0], fdata[2 * i + 1]);
                        return true;
                    }
                    return false;

                case TiffTag.XMLPACKET:
                    string s = raw_data as string;
                    if (s != null)
                    {
                        fprintf(fd, "  XMLPacket (XMP Metadata):\n");
                        fprintf(fd, s.Substring(0, value_count));
                        fprintf(fd, "\n");
                        return true;
                    }
                    return false;

                case TiffTag.RICHTIFFIPTC:
                    // XXX: for some weird reason RichTIFFIPTC tag defined
                    // as array of LONG values.
                    fprintf(fd, "  RichTIFFIPTC Data: <present>, {0} bytes\n", value_count * 4);
                    return true;

                case TiffTag.PHOTOSHOP:
                    fprintf(fd, "  Photoshop Data: <present>, {0} bytes\n", value_count);
                    return true;

                case TiffTag.ICCPROFILE:
                    fprintf(fd, "  ICC Profile: <present>, {0} bytes\n", value_count);
                    return true;

                case TiffTag.STONITS:
                    if (ddata != null)
                    {
                        fprintf(fd, "  Sample to Nits conversion factor: {0:e4}\n", ddata[0]);
                        return true;
                    }
                    return false;
            }

            return false;
        }