Beispiel #1
0
func ParseIFD(br tiff.BReader, offset uint64, tsp tiff.TagSpace, ftsp tiff.FieldTypeSpace) (out tiff.IFD, err error) {
	if br == nil {
		return nil, errors.New("tiff: no BReader supplied")
	}
	if ftsp == nil {
		ftsp = tiff.DefaultFieldTypeSpace
	}
	if tsp == nil {
		tsp = tiff.DefaultTagSpace
	}
	ifd := &imageFileDirectory{
		fieldMap: make(map[uint16]tiff.Field, 1),
	}
	br.Seek(int64(offset), 0)
	if err = br.BRead(&ifd.numEntries); err != nil {
		err = fmt.Errorf("bigtiff: unable to read the number of entries for the IFD at offset %#08x: %v", offset, err)
		return
	}
	for i := uint64(0); i < ifd.numEntries; i++ {
		var f tiff.Field
		if f, err = ParseField(br, tsp, ftsp); err != nil {
			return
		}
		ifd.fields = append(ifd.fields, f)
		ifd.fieldMap[f.Tag().ID()] = f
	}
	if err = br.BRead(&ifd.nextOffset); err != nil {
		err = fmt.Errorf("bigtiff: unable to read the offset for the next ifd: %v", err)
		return
	}
	return ifd, nil
}
Beispiel #2
0
func ParseEntry(br tiff.BReader) (out Entry, err error) {
	e := new(entry)
	if err = br.BRead(&e.tagID); err != nil {
		return
	}
	if err = br.BRead(&e.typeID); err != nil {
		return
	}
	if err = br.BRead(&e.count); err != nil {
		return
	}
	if err = br.BRead(&e.valueOffset); err != nil {
		return
	}
	return e, nil
}