static void format_title(const char *filename, WCHAR *title, unsigned max_size) { FLAC__StreamMetadata *tags; ReadTags(filename, &tags, /*forDisplay=*/true); tagz_format(flac_cfg.title.tag_format_w, get_tag, free_tag, tags, title, max_size); FLAC_plugin__tags_destroy(&tags); }
Language* LanguageReader::Read( string p_definitionFilePath ) { ifstream eye; eye.open(p_definitionFilePath.c_str()); if(eye.is_open()) { ReadVariables(eye); ReadTokenTypes(eye); ReadStates(eye); ReadTags(eye); eye.close(); return new Language(new DFA(m_startState, m_errorState, m_states), m_reservedWordsToTokenTypeIdMap); } return NULL; }
ERRORCODE near CTIFFInfo::ReadInfo(LPINT pWidth, LPINT pHeight, \ LPINT pXResolution, LPINT pYResolution) { TIFF_DATA Data; TIFF_ENTRY* pEntry; ERRORCODE error; if (m_Info.valid) { return ERRORCODE_None; } /* Read all tags. */ if ((error = ReadTags()) != ERRORCODE_None) { return error; } /* Read the image resolutions. */ /* // A particular TIFF writer only writes one resolution. So we check both // in the correct order. */ if (GetData(TIFF_XResolution, 0L, &Data) == ERRORCODE_None || GetData(TIFF_YResolution, 0L, &Data) == ERRORCODE_None) { if (Data.Rational.denominator == 0) { Data.Rational.denominator = 1; } *pXResolution = (int)((Data.Rational.numerator) / (Data.Rational.denominator)); } if (GetData(TIFF_YResolution, 0L, &Data) == ERRORCODE_None || GetData(TIFF_XResolution, 0L, &Data) == ERRORCODE_None) { if (Data.Rational.denominator == 0) { Data.Rational.denominator = 1; } *pYResolution = (int)((Data.Rational.numerator) / (Data.Rational.denominator)); } /* Read the width. */ if (GetData(TIFF_ImageWidth, 0L, &Data) != ERRORCODE_None) { /* No width! */ return ERRORCODE_IllegalType; } *pWidth = m_Info.width = Data.Short; /* Read the length. */ if (GetData(TIFF_ImageLength, 0L, &Data) != ERRORCODE_None) { /* No height! */ return ERRORCODE_IllegalType; } *pHeight = m_Info.height = Data.Short; /* Read the number of bits per sample. */ GetData(TIFF_BitsPerSample, 0L, &Data); m_Info.bits_per_sample = Data.Short; /* // Read the number of samples per pixel. */ GetData(TIFF_SamplesPerPixel, 0L, &Data); m_Info.samples_per_pixel = Data.Short; m_Info.byte_width=((m_Info.width*m_Info.bits_per_sample+7)/8)*Data.Short; /* Read the photometric interpretation. */ if (GetData(TIFF_PhotometricInterp, 0L, &Data) == ERRORCODE_None) { m_Info.photometric = Data.Short; } else { /* No interpretation! */ m_Info.photometric = 0; } /* // Read the number of rows per strip. // No error check is done because this value has a default, and if it got // this far, the tags have been read. */ GetData(TIFF_RowsPerStrip, 0L, &Data); m_Info.rows_per_strip = Data.Short; if ((Data.Short == -1) || (Data.Short > m_Info.height)) { m_Info.rows_per_strip = m_Info.height; } /* // Read the planar configuration. // No error check is done because this value has a default, and if it got // this far, the tags have been read. */ GetData(TIFF_PlanarConfiguration, 0L, &Data); m_Info.planar_configuration = Data.Short; if (m_Info.samples_per_pixel != 1 && m_Info.planar_configuration == 2) { /* Bad configuration! */ return ERRORCODE_IllegalType; } /* // Read the compression value. // No error check is done because this value has a default, and if it got // this far, the tags have been read. */ GetData(TIFF_Compression, 0L, &Data); m_Info.compression = Data.Short; /* // Read the strip offsets value. // We don't use get_tiff_data here because we want the value in // the tag field regardless of whether it is actual data or a pointer // to disk data. get_tiff_data would actually read the disk data if we // used it. */ pEntry = FindEntry(TIFF_StripOffsets); if (!pEntry->entry_valid) { /* No default for strip offsets! */ return ERRORCODE_IllegalType; } m_Info.strip_offsets = pEntry->entry.value_offset; if (m_Info.byte_order != BYTE_ORDER_IBM) { swap_long(&m_Info.strip_offsets); } if (pEntry->entry.length == 1 && pEntry->entry.type == TIFF_SHORT) { /* Make sure we only read the short value. */ m_Info.strip_offsets &= 0x0FFFFL; } /* // Read the gray response curve data or color map data if it exists. */ m_Info.palette_offset = -1L; if (m_Info.bits_per_sample > 1) { /* Gray scale! */ if ((pEntry = FindEntry(TIFF_GrayResponseCurve))->entry_valid) { LONG curve_length; /* We have a curve. */ m_Info.palette_offset = pEntry->entry.value_offset; curve_length = pEntry->entry.length; if (m_Info.byte_order != BYTE_ORDER_IBM) { swap_long(&curve_length); swap_long(&m_Info.palette_offset); } m_Info.gray_response_length = (SHORT)curve_length; GetData(TIFF_GrayResponseUnit, 0L, &Data); m_Info.gray_response_unit = Data.Short; /* Don't invert data. */ m_pEntries[Tindex_PhotometricInterp].entry.value_offset = m_Info.photometric = 1; } else if ((pEntry = FindEntry(TIFF_ColorMap))->entry_valid) { m_Info.gray_response_unit = -1; /* Flag as ColorMap */ /* We have a color map. Store the offset. */ m_Info.palette_offset = pEntry->entry.value_offset; /* Fix the offset if necessary. */ if (m_Info.byte_order != BYTE_ORDER_IBM) { swap_long(&m_Info.palette_offset); } } } GetData(TIFF_Predictor, 0L, &Data); m_Info.predictor = Data.Short; return ERRORCODE_None; }