removed duplicated and obsolete tiff translator
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23997 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dc0d6e4c0d
commit
96f0c48768
@ -1,99 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// BitReader
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// BitReader.cpp
|
||||
//
|
||||
// Wrapper class for StreamBuffer to make it convenient to read 1 bit at
|
||||
// a time
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "BitReader.h"
|
||||
|
||||
BitReader::BitReader(uint16 fillOrder, StreamBuffer *pstreambuf, bool binitialRead)
|
||||
{
|
||||
SetTo(fillOrder, pstreambuf, binitialRead);
|
||||
}
|
||||
|
||||
BitReader::~BitReader()
|
||||
{
|
||||
finitStatus = B_ERROR;
|
||||
fpstreambuf = NULL;
|
||||
fbitbuf = 0;
|
||||
fcurrentbit = 0;
|
||||
}
|
||||
|
||||
status_t
|
||||
BitReader::SetTo(uint16 fillOrder, StreamBuffer *pstreambuf, bool binitialRead)
|
||||
{
|
||||
finitStatus = B_OK;
|
||||
fnbytesRead = 0;
|
||||
fbitbuf = 0;
|
||||
fcurrentbit = 0;
|
||||
fpstreambuf = pstreambuf;
|
||||
ffillOrder = fillOrder;
|
||||
if (ffillOrder != 1 && ffillOrder != 2)
|
||||
finitStatus = B_BAD_VALUE;
|
||||
else if (!fpstreambuf)
|
||||
finitStatus = B_BAD_VALUE;
|
||||
else if (binitialRead)
|
||||
finitStatus = ReadByte();
|
||||
|
||||
return finitStatus;
|
||||
}
|
||||
|
||||
status_t
|
||||
BitReader::NextBit()
|
||||
{
|
||||
status_t result;
|
||||
result = PeekBit();
|
||||
if (result >= 0)
|
||||
fcurrentbit--;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
BitReader::PeekBit()
|
||||
{
|
||||
// if fcurrentbit is zero, read in next byte
|
||||
if (!fcurrentbit && ReadByte() != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
if (ffillOrder == 1)
|
||||
return (fbitbuf >> (fcurrentbit - 1)) & 1;
|
||||
else
|
||||
return (fbitbuf >> (8 - fcurrentbit)) & 1;
|
||||
}
|
||||
|
||||
status_t
|
||||
BitReader::ReadByte()
|
||||
{
|
||||
if (fpstreambuf->Read(&fbitbuf, 1) != 1)
|
||||
return B_ERROR;
|
||||
|
||||
fnbytesRead++;
|
||||
fcurrentbit = 8;
|
||||
return B_OK;
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// BitReader
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// BitReader.h
|
||||
//
|
||||
// Wrapper class for StreamBuffer to make it convenient to read 1 bit at
|
||||
// a time
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef BIT_READER_H
|
||||
#define BIT_READER_H
|
||||
|
||||
#include "StreamBuffer.h"
|
||||
|
||||
class BitReader {
|
||||
public:
|
||||
// Setup the BitReader to read from the given stream with the given fill order
|
||||
BitReader(uint16 fillOrder, StreamBuffer *pstreambuf, bool binitialRead = true);
|
||||
~BitReader();
|
||||
|
||||
// Change the BitReader to read from given stream with the given fill order
|
||||
status_t SetTo(uint16 fillOrder, StreamBuffer *pstreambuf, bool binitialRead = true);
|
||||
|
||||
status_t InitCheck() const { return finitStatus; };
|
||||
|
||||
uint32 BytesRead() const { return fnbytesRead; };
|
||||
uint32 BitsInBuffer() const { return fcurrentbit; };
|
||||
|
||||
// return the current bit and increment the position
|
||||
// If the result is negative, an error occured
|
||||
status_t NextBit();
|
||||
|
||||
// return the current bit without incrementing the position
|
||||
// (if buffer is empty, will read next byte in StreamBuffer)
|
||||
// If the result is negative, an error occured
|
||||
status_t PeekBit();
|
||||
|
||||
private:
|
||||
status_t ReadByte();
|
||||
|
||||
StreamBuffer *fpstreambuf;
|
||||
status_t finitStatus;
|
||||
uint32 fnbytesRead;
|
||||
uint16 ffillOrder;
|
||||
uint8 fbitbuf;
|
||||
uint8 fcurrentbit;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,398 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// DecodeTree
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// DecodeTree.cpp
|
||||
//
|
||||
// This object is used for fast decoding of Huffman encoded data
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "DecodeTree.h"
|
||||
|
||||
// Encodings used to populate
|
||||
// the decode trees
|
||||
const HuffmanEncoding g_encWhiteTerm[] = {
|
||||
{0, 0x35, 8}, // "00110101"
|
||||
{1, 0x07, 6}, // "000111"
|
||||
{2, 0x07, 4}, // "0111"
|
||||
{3, 0x08, 4}, // "1000"
|
||||
{4, 0x0b, 4}, // "1011"
|
||||
{5, 0x0c, 4}, // "1100"
|
||||
{6, 0x0e, 4}, // "1110"
|
||||
{7, 0x0f, 4}, // "1111"
|
||||
{8, 0x13, 5}, // "10011"
|
||||
{9, 0x14, 5}, // "10100"
|
||||
{10, 0x07, 5}, // "00111"
|
||||
{11, 0x08, 5}, // "01000"
|
||||
{12, 0x08, 6}, // "001000"
|
||||
{13, 0x03, 6}, // "000011"
|
||||
{14, 0x34, 6}, // "110100"
|
||||
{15, 0x35, 6}, // "110101"
|
||||
{16, 0x2a, 6}, // "101010"
|
||||
{17, 0x2b, 6}, // "101011"
|
||||
{18, 0x27, 7}, // "0100111"
|
||||
{19, 0x0c, 7}, // "0001100"
|
||||
{20, 0x08, 7}, // "0001000"
|
||||
{21, 0x17, 7}, // "0010111"
|
||||
{22, 0x03, 7}, // "0000011"
|
||||
{23, 0x04, 7}, // "0000100"
|
||||
{24, 0x28, 7}, // "0101000"
|
||||
{25, 0x2b, 7}, // "0101011"
|
||||
{26, 0x13, 7}, // "0010011"
|
||||
{27, 0x24, 7}, // "0100100"
|
||||
{28, 0x18, 7}, // "0011000"
|
||||
{29, 0x02, 8}, // "00000010"
|
||||
{30, 0x03, 8}, // "00000011"
|
||||
{31, 0x1a, 8}, // "00011010"
|
||||
{32, 0x1b, 8}, // "00011011"
|
||||
{33, 0x12, 8}, // "00010010"
|
||||
{34, 0x13, 8}, // "00010011"
|
||||
{35, 0x14, 8}, // "00010100"
|
||||
{36, 0x15, 8}, // "00010101"
|
||||
{37, 0x16, 8}, // "00010110"
|
||||
{38, 0x17, 8}, // "00010111"
|
||||
{39, 0x28, 8}, // "00101000"
|
||||
{40, 0x29, 8}, // "00101001"
|
||||
{41, 0x2a, 8}, // "00101010"
|
||||
{42, 0x2b, 8}, // "00101011"
|
||||
{43, 0x2c, 8}, // "00101100"
|
||||
{44, 0x2d, 8}, // "00101101"
|
||||
{45, 0x04, 8}, // "00000100"
|
||||
{46, 0x05, 8}, // "00000101"
|
||||
{47, 0x0a, 8}, // "00001010"
|
||||
{48, 0x0b, 8}, // "00001011"
|
||||
{49, 0x52, 8}, // "01010010"
|
||||
{50, 0x53, 8}, // "01010011"
|
||||
{51, 0x54, 8}, // "01010100"
|
||||
{52, 0x55, 8}, // "01010101"
|
||||
{53, 0x24, 8}, // "00100100"
|
||||
{54, 0x25, 8}, // "00100101"
|
||||
{55, 0x58, 8}, // "01011000"
|
||||
{56, 0x59, 8}, // "01011001"
|
||||
{57, 0x5a, 8}, // "01011010"
|
||||
{58, 0x5b, 8}, // "01011011"
|
||||
{59, 0x4a, 8}, // "01001010"
|
||||
{60, 0x4b, 8}, // "01001011"
|
||||
{61, 0x32, 8}, // "00110010"
|
||||
{62, 0x33, 8}, // "00110011"
|
||||
{63, 0x34, 8}, // "00110100"
|
||||
}; // g_encWhiteTerm
|
||||
|
||||
const HuffmanEncoding g_encWhiteMakeup[] = {
|
||||
{64, 0x1b, 5}, // "11011"
|
||||
{128, 0x12, 5}, // "10010"
|
||||
{192, 0x17, 6}, // "010111"
|
||||
{256, 0x37, 7}, // "0110111"
|
||||
{320, 0x36, 8}, // "00110110"
|
||||
{384, 0x37, 8}, // "00110111"
|
||||
{448, 0x64, 8}, // "01100100"
|
||||
{512, 0x65, 8}, // "01100101"
|
||||
{576, 0x68, 8}, // "01101000"
|
||||
{640, 0x67, 8}, // "01100111"
|
||||
{704, 0xcc, 9}, // "011001100"
|
||||
{768, 0xcd, 9}, // "011001101"
|
||||
{832, 0xd2, 9}, // "011010010"
|
||||
{896, 0xd3, 9}, // "011010011"
|
||||
{960, 0xd4, 9}, // "011010100"
|
||||
{1024, 0xd5, 9}, // "011010101"
|
||||
{1088, 0xd6, 9}, // "011010110"
|
||||
{1152, 0xd7, 9}, // "011010111"
|
||||
{1216, 0xd8, 9}, // "011011000"
|
||||
{1280, 0xd9, 9}, // "011011001"
|
||||
{1344, 0xda, 9}, // "011011010"
|
||||
{1408, 0xdb, 9}, // "011011011"
|
||||
{1472, 0x98, 9}, // "010011000"
|
||||
{1536, 0x99, 9}, // "010011001"
|
||||
{1600, 0x9a, 9}, // "010011010"
|
||||
{1664, 0x18, 6}, // "011000"
|
||||
{1728, 0x9b, 9}, // "010011011"
|
||||
}; // g_encWhiteMakeup
|
||||
|
||||
const HuffmanEncoding g_encBlackTerm[] = {
|
||||
{0, 0x37, 10}, // "0000110111"
|
||||
{1, 0x02, 3}, // "010"
|
||||
{2, 0x03, 2}, // "11"
|
||||
{3, 0x02, 2}, // "10"
|
||||
{4, 0x03, 3}, // "011"
|
||||
{5, 0x03, 4}, // "0011"
|
||||
{6, 0x02, 4}, // "0010"
|
||||
{7, 0x03, 5}, // "00011"
|
||||
{8, 0x05, 6}, // "000101"
|
||||
{9, 0x04, 6}, // "000100"
|
||||
{10, 0x04, 7}, // "0000100"
|
||||
{11, 0x05, 7}, // "0000101"
|
||||
{12, 0x07, 7}, // "0000111"
|
||||
{13, 0x04, 8}, // "00000100"
|
||||
{14, 0x07, 8}, // "00000111"
|
||||
{15, 0x18, 9}, // "000011000"
|
||||
{16, 0x17, 10}, // "0000010111"
|
||||
{17, 0x18, 10}, // "0000011000"
|
||||
{18, 0x08, 10}, // "0000001000"
|
||||
{19, 0x67, 11}, // "00001100111"
|
||||
{20, 0x68, 11}, // "00001101000"
|
||||
{21, 0x6c, 11}, // "00001101100"
|
||||
{22, 0x37, 11}, // "00000110111"
|
||||
{23, 0x28, 11}, // "00000101000"
|
||||
{24, 0x17, 11}, // "00000010111"
|
||||
{25, 0x18, 11}, // "00000011000"
|
||||
{26, 0xca, 12}, // "000011001010"
|
||||
{27, 0xcb, 12}, // "000011001011"
|
||||
{28, 0xcc, 12}, // "000011001100"
|
||||
{29, 0xcd, 12}, // "000011001101"
|
||||
{30, 0x68, 12}, // "000001101000"
|
||||
{31, 0x69, 12}, // "000001101001"
|
||||
{32, 0x6a, 12}, // "000001101010"
|
||||
{33, 0x6b, 12}, // "000001101011"
|
||||
{34, 0xd2, 12}, // "000011010010"
|
||||
{35, 0xd3, 12}, // "000011010011"
|
||||
{36, 0xd4, 12}, // "000011010100"
|
||||
{37, 0xd5, 12}, // "000011010101"
|
||||
{38, 0xd6, 12}, // "000011010110"
|
||||
{39, 0xd7, 12}, // "000011010111"
|
||||
{40, 0x6c, 12}, // "000001101100"
|
||||
{41, 0x6d, 12}, // "000001101101"
|
||||
{42, 0xda, 12}, // "000011011010"
|
||||
{43, 0xdb, 12}, // "000011011011"
|
||||
{44, 0x54, 12}, // "000001010100"
|
||||
{45, 0x55, 12}, // "000001010101"
|
||||
{46, 0x56, 12}, // "000001010110"
|
||||
{47, 0x57, 12}, // "000001010111"
|
||||
{48, 0x64, 12}, // "000001100100"
|
||||
{49, 0x65, 12}, // "000001100101"
|
||||
{50, 0x52, 12}, // "000001010010"
|
||||
{51, 0x53, 12}, // "000001010011"
|
||||
{52, 0x24, 12}, // "000000100100"
|
||||
{53, 0x37, 12}, // "000000110111"
|
||||
{54, 0x38, 12}, // "000000111000"
|
||||
{55, 0x27, 12}, // "000000100111"
|
||||
{56, 0x28, 12}, // "000000101000"
|
||||
{57, 0x58, 12}, // "000001011000"
|
||||
{58, 0x59, 12}, // "000001011001"
|
||||
{59, 0x2b, 12}, // "000000101011"
|
||||
{60, 0x2c, 12}, // "000000101100"
|
||||
{61, 0x5a, 12}, // "000001011010"
|
||||
{62, 0x66, 12}, // "000001100110"
|
||||
{63, 0x67, 12}, // "000001100111"
|
||||
}; // g_encBlackTerm
|
||||
|
||||
const HuffmanEncoding g_encBlackMakeup[] = {
|
||||
{64, 0x0f, 10}, // "0000001111"
|
||||
{128, 0xc8, 12}, // "000011001000"
|
||||
{192, 0xc9, 12}, // "000011001001"
|
||||
{256, 0x5b, 12}, // "000001011011"
|
||||
{320, 0x33, 12}, // "000000110011"
|
||||
{384, 0x34, 12}, // "000000110100"
|
||||
{448, 0x35, 12}, // "000000110101"
|
||||
{512, 0x6c, 13}, // "0000001101100"
|
||||
{576, 0x6d, 13}, // "0000001101101"
|
||||
{640, 0x4a, 13}, // "0000001001010"
|
||||
{704, 0x4b, 13}, // "0000001001011"
|
||||
{768, 0x4c, 13}, // "0000001001100"
|
||||
{832, 0x4d, 13}, // "0000001001101"
|
||||
{896, 0x72, 13}, // "0000001110010"
|
||||
{960, 0x73, 13}, // "0000001110011"
|
||||
{1024, 0x74, 13}, // "0000001110100"
|
||||
{1088, 0x75, 13}, // "0000001110101"
|
||||
{1152, 0x76, 13}, // "0000001110110"
|
||||
{1216, 0x77, 13}, // "0000001110111"
|
||||
{1280, 0x52, 13}, // "0000001010010"
|
||||
{1344, 0x53, 13}, // "0000001010011"
|
||||
{1408, 0x54, 13}, // "0000001010100"
|
||||
{1472, 0x55, 13}, // "0000001010101"
|
||||
{1536, 0x5a, 13}, // "0000001011010"
|
||||
{1600, 0x5b, 13}, // "0000001011011"
|
||||
{1664, 0x64, 13}, // "0000001100100"
|
||||
{1728, 0x65, 13}, // "0000001100101"
|
||||
}; // g_encBlackMakeup
|
||||
|
||||
const HuffmanEncoding g_encBothMakeup[] = {
|
||||
{1792, 0x08, 11}, // "00000001000"
|
||||
{1856, 0x0c, 11}, // "00000001100"
|
||||
{1920, 0x0d, 11}, // "00000001101"
|
||||
{1984, 0x12, 12}, // "000000010010"
|
||||
{2048, 0x13, 12}, // "000000010011"
|
||||
{2112, 0x14, 12}, // "000000010100"
|
||||
{2176, 0x15, 12}, // "000000010101"
|
||||
{2240, 0x16, 12}, // "000000010110"
|
||||
{2304, 0x17, 12}, // "000000010111"
|
||||
{2368, 0x1c, 12}, // "000000011100"
|
||||
{2432, 0x1d, 12}, // "000000011101"
|
||||
{2496, 0x1e, 12}, // "000000011110"
|
||||
{2560, 0x1f, 12}, // "000000011111"
|
||||
}; // g_encBothMakeup
|
||||
|
||||
|
||||
DecodeTree::DecodeTree(bool bwhite)
|
||||
{
|
||||
finitStatus = B_ERROR;
|
||||
fptop = new DecodeNode;
|
||||
if (fptop) {
|
||||
fptop->value = -1;
|
||||
fptop->branches[0] = NULL;
|
||||
fptop->branches[1] = NULL;
|
||||
|
||||
if (bwhite)
|
||||
finitStatus = LoadWhiteEncodings();
|
||||
else
|
||||
finitStatus = LoadBlackEncodings();
|
||||
} else
|
||||
finitStatus = B_NO_MEMORY;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_node(DecodeNode *pnode)
|
||||
{
|
||||
if (pnode->branches[0])
|
||||
destroy_node(pnode->branches[0]);
|
||||
if (pnode->branches[1])
|
||||
destroy_node(pnode->branches[1]);
|
||||
|
||||
delete pnode;
|
||||
}
|
||||
DecodeTree::~DecodeTree()
|
||||
{
|
||||
if (fptop) {
|
||||
destroy_node(fptop);
|
||||
fptop = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
status_t
|
||||
DecodeTree::LoadBlackEncodings()
|
||||
{
|
||||
status_t result = B_ERROR;
|
||||
|
||||
result = AddEncodings(g_encBlackTerm,
|
||||
sizeof(g_encBlackTerm) / sizeof(HuffmanEncoding));
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
result = AddEncodings(g_encBlackMakeup,
|
||||
sizeof(g_encBlackMakeup) / sizeof(HuffmanEncoding));
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
result = AddEncodings(g_encBothMakeup,
|
||||
sizeof(g_encBothMakeup) / sizeof(HuffmanEncoding));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
DecodeTree::LoadWhiteEncodings()
|
||||
{
|
||||
status_t result = B_ERROR;
|
||||
|
||||
result = AddEncodings(g_encWhiteTerm,
|
||||
sizeof(g_encWhiteTerm) / sizeof(HuffmanEncoding));
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
result = AddEncodings(g_encWhiteMakeup,
|
||||
sizeof(g_encWhiteMakeup) / sizeof(HuffmanEncoding));
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
result = AddEncodings(g_encBothMakeup,
|
||||
sizeof(g_encBothMakeup) / sizeof(HuffmanEncoding));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
DecodeTree::AddEncodings(const HuffmanEncoding *pencs, uint32 length)
|
||||
{
|
||||
status_t result = B_ERROR;
|
||||
for (uint32 i = 0; i < length; i++) {
|
||||
result = AddEncoding(pencs[i].encoding, pencs[i].length,
|
||||
pencs[i].value);
|
||||
if (result != B_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t
|
||||
DecodeTree::AddEncoding(uint16 encoding, uint8 length, uint16 value)
|
||||
{
|
||||
if (!length || length > 16)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
DecodeNode *pcurrent = fptop, *pnext = NULL;
|
||||
uint8 bitsleft = length;
|
||||
|
||||
while (bitsleft > 0) {
|
||||
uint32 branch = (encoding >> (bitsleft - 1)) & 1;
|
||||
|
||||
// if a new node needs to be allocated
|
||||
if (!pcurrent->branches[branch]) {
|
||||
pcurrent->branches[branch] = new DecodeNode;
|
||||
pnext = pcurrent->branches[branch];
|
||||
if (!pnext)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
pnext->value = -1;
|
||||
pnext->branches[0] = NULL;
|
||||
pnext->branches[1] = NULL;
|
||||
|
||||
} else
|
||||
// if a node exists
|
||||
pnext = pcurrent->branches[branch];
|
||||
|
||||
if (bitsleft == 1) {
|
||||
pnext->value = value;
|
||||
return B_OK;
|
||||
|
||||
} else {
|
||||
pcurrent = pnext;
|
||||
bitsleft--;
|
||||
}
|
||||
}
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
DecodeTree::GetValue(BitReader &stream) const
|
||||
{
|
||||
if (InitCheck() != B_OK)
|
||||
return InitCheck();
|
||||
|
||||
status_t branch;
|
||||
DecodeNode *pnode = fptop;
|
||||
while (pnode) {
|
||||
branch = stream.NextBit();
|
||||
if (branch < 0)
|
||||
return branch;
|
||||
|
||||
pnode = pnode->branches[branch];
|
||||
if (!pnode)
|
||||
return B_ERROR;
|
||||
else if (pnode->value > -1)
|
||||
return pnode->value;
|
||||
}
|
||||
|
||||
return B_ERROR;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// DecodeTree
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// DecodeTree.h
|
||||
//
|
||||
// This object is used for fast decoding of Huffman encoded data
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef DECODE_TREE_H
|
||||
#define DECODE_TREE_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include "BitReader.h"
|
||||
|
||||
// structure used to populate
|
||||
// the decode trees
|
||||
struct HuffmanEncoding {
|
||||
uint16 value;
|
||||
uint8 encoding;
|
||||
uint8 length;
|
||||
};
|
||||
|
||||
// node used by the decode tree
|
||||
struct DecodeNode {
|
||||
int16 value;
|
||||
DecodeNode *branches[2];
|
||||
};
|
||||
|
||||
class DecodeTree {
|
||||
public:
|
||||
DecodeTree(bool bwhite);
|
||||
~DecodeTree();
|
||||
|
||||
// returns B_OK if the tree was initialized without error,
|
||||
// returns B_ERROR or B_NO_MEMORY if unable to initialize
|
||||
status_t InitCheck() const { return finitStatus; };
|
||||
|
||||
// Decodes nbits bits from encdata, starting with the
|
||||
// highest order bit. If successful, returns the corresponding
|
||||
// value for the encdata and bitsread contains the
|
||||
// number of bits from encdata that were decoded. If not successful,
|
||||
// B_ERROR, B_NO_MEMORY or B_BAD_VALUE is returned
|
||||
status_t GetValue(BitReader &stream) const;
|
||||
|
||||
private:
|
||||
status_t LoadBlackEncodings();
|
||||
status_t LoadWhiteEncodings();
|
||||
status_t AddEncodings(const HuffmanEncoding *pencs, uint32 length);
|
||||
status_t AddEncoding(uint16 encoding, uint8 length, uint16 value);
|
||||
|
||||
status_t finitStatus;
|
||||
DecodeNode *fptop;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
SubDir HAIKU_TOP src add-ons translators tiff ;
|
||||
|
||||
# Include StreamBuffer code from shared directory
|
||||
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ;
|
||||
|
||||
Translator TIFFTranslator :
|
||||
StreamBuffer.cpp
|
||||
BitReader.cpp
|
||||
DecodeTree.cpp
|
||||
TiffField.cpp
|
||||
TiffUintField.cpp
|
||||
TiffUnknownField.cpp
|
||||
TiffIfd.cpp
|
||||
TiffIfdList.cpp
|
||||
TIFFMain.cpp
|
||||
TIFFTranslator.cpp
|
||||
TIFFView.cpp
|
||||
TIFFWindow.cpp
|
||||
|
||||
: be translation
|
||||
: true
|
||||
;
|
@ -1,103 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// Version:
|
||||
//
|
||||
// This translator opens and writes TIFF images.
|
||||
//
|
||||
//
|
||||
// This application and all source files used in its construction, except
|
||||
// where noted, are licensed under the MIT License, and have been written
|
||||
// and are:
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include "TIFFTranslator.h"
|
||||
#include "TIFFWindow.h"
|
||||
#include "TIFFView.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// main
|
||||
//
|
||||
// Creates a BWindow for displaying info about the TIFFTranslator
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
int
|
||||
main()
|
||||
{
|
||||
BApplication app("application/x-vnd.obos-tiff-translator");
|
||||
TIFFTranslator *ptranslator = new TIFFTranslator;
|
||||
BView *view = NULL;
|
||||
BRect rect(0, 0, 225, 175);
|
||||
if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
|
||||
BAlert *err = new BAlert("Error",
|
||||
"Unable to create the TIFFTranslator view.", "OK");
|
||||
err->Go();
|
||||
return 1;
|
||||
}
|
||||
// release the translator even though I never really used it anyway
|
||||
ptranslator->Release();
|
||||
ptranslator = NULL;
|
||||
|
||||
TIFFWindow *wnd = new TIFFWindow(rect);
|
||||
view->ResizeTo(rect.Width(), rect.Height());
|
||||
wnd->AddChild(view);
|
||||
BPoint wndpt = B_ORIGIN;
|
||||
{
|
||||
BScreen scrn;
|
||||
BRect frame = scrn.Frame();
|
||||
frame.InsetBy(10, 23);
|
||||
// if the point is outside of the screen frame,
|
||||
// use the mouse location to find a better point
|
||||
if (!frame.Contains(wndpt)) {
|
||||
uint32 dummy;
|
||||
view->GetMouse(&wndpt, &dummy, false);
|
||||
wndpt.x -= rect.Width() / 2;
|
||||
wndpt.y -= rect.Height() / 2;
|
||||
// clamp location to screen
|
||||
if (wndpt.x < frame.left)
|
||||
wndpt.x = frame.left;
|
||||
if (wndpt.y < frame.top)
|
||||
wndpt.y = frame.top;
|
||||
if (wndpt.x > frame.right)
|
||||
wndpt.x = frame.right;
|
||||
if (wndpt.y > frame.bottom)
|
||||
wndpt.y = frame.bottom;
|
||||
}
|
||||
}
|
||||
wnd->MoveTo(wndpt);
|
||||
wnd->Show();
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,160 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFTranslator.h
|
||||
//
|
||||
// This BTranslator based object is for opening and writing
|
||||
// TIFF images.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_TRANSLATOR_H
|
||||
#define TIFF_TRANSLATOR_H
|
||||
|
||||
#include <Translator.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <ByteOrder.h>
|
||||
#include <fs_attr.h>
|
||||
#include "DecodeTree.h"
|
||||
|
||||
// IO Extension Names:
|
||||
#define DOCUMENT_COUNT "/documentCount"
|
||||
#define DOCUMENT_INDEX "/documentIndex"
|
||||
|
||||
#define TIFF_TRANSLATOR_VERSION 100
|
||||
|
||||
#define TIFF_IN_QUALITY 0.1
|
||||
#define TIFF_IN_CAPABILITY 0.1
|
||||
#define TIFF_OUT_QUALITY 0.6
|
||||
#define TIFF_OUT_CAPABILITY 0.2
|
||||
|
||||
#define BBT_IN_QUALITY 0.4
|
||||
#define BBT_IN_CAPABILITY 0.6
|
||||
#define BBT_OUT_QUALITY 0.4
|
||||
#define BBT_OUT_CAPABILITY 0.6
|
||||
|
||||
enum TIFF_IMAGE_TYPE {
|
||||
TIFF_BILEVEL = 1,
|
||||
TIFF_PALETTE,
|
||||
TIFF_RGB,
|
||||
TIFF_CMYK
|
||||
};
|
||||
|
||||
// class for storing only the TIFF fields
|
||||
// that are of interest to the TIFFTranslator
|
||||
//
|
||||
// The class is very minimal so that it is
|
||||
// convenient to use, but cleans up after itself
|
||||
class TiffDetails {
|
||||
public:
|
||||
TiffDetails();
|
||||
~TiffDetails();
|
||||
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
uint32 compression;
|
||||
uint32 t4options;
|
||||
uint32 rowsPerStrip;
|
||||
uint32 stripsPerImage;
|
||||
uint32 *pstripOffsets;
|
||||
uint32 *pstripByteCounts;
|
||||
uint8 *pcolorMap;
|
||||
uint16 interpretation;
|
||||
uint16 bitsPerPixel;
|
||||
uint16 imageType;
|
||||
uint16 fillOrder;
|
||||
};
|
||||
|
||||
class TIFFTranslator : public BTranslator {
|
||||
public:
|
||||
TIFFTranslator();
|
||||
|
||||
virtual const char *TranslatorName() const;
|
||||
// returns the short name of the translator
|
||||
|
||||
virtual const char *TranslatorInfo() const;
|
||||
// returns a verbose name/description for the translator
|
||||
|
||||
virtual int32 TranslatorVersion() const;
|
||||
// returns the version of the translator
|
||||
|
||||
virtual const translation_format *InputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the input formats and the count of input formats
|
||||
// that this translator supports
|
||||
|
||||
virtual const translation_format *OutputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the output formats and the count of output formats
|
||||
// that this translator supports
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType);
|
||||
// determines whether or not this translator can convert the
|
||||
// data in inSource to the type outType
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination);
|
||||
// this function is the whole point of the Translation Kit,
|
||||
// it translates the data in inSource to outDestination
|
||||
// using the format outType
|
||||
|
||||
virtual status_t MakeConfigurationView(BMessage *ioExtension,
|
||||
BView **outView, BRect *outExtent);
|
||||
// creates and returns the view for displaying information
|
||||
// about this translator
|
||||
|
||||
protected:
|
||||
virtual ~TIFFTranslator();
|
||||
// this is protected because the object is deleted by the
|
||||
// Release() function instead of being deleted directly by
|
||||
// the user
|
||||
|
||||
private:
|
||||
status_t LoadHuffmanTrees();
|
||||
|
||||
ssize_t decode_huffman(StreamBuffer *pstreambuf, TiffDetails &details,
|
||||
uint8 *pbits);
|
||||
ssize_t decode_t4(BitReader &stream, TiffDetails &details,
|
||||
uint8 *pbits, bool bfirstLine);
|
||||
|
||||
status_t translate_from_tiff(BPositionIO *inSource, BMessage *ioExtension,
|
||||
ssize_t amtread, uint8 *read, swap_action swp, uint32 outType,
|
||||
BPositionIO *outDestination);
|
||||
|
||||
DecodeTree *fpblackTree;
|
||||
DecodeTree *fpwhiteTree;
|
||||
|
||||
char fName[30];
|
||||
char fInfo[100];
|
||||
};
|
||||
|
||||
#endif // #ifndef TIFF_TRANSLATOR_H
|
@ -1,116 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFView.cpp
|
||||
//
|
||||
// This BView based object displays information about the TIFFTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "TIFFView.h"
|
||||
#include "TIFFTranslator.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the view settings
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFView::TIFFView(const BRect &frame, const char *name,
|
||||
uint32 resize, uint32 flags)
|
||||
: BView(frame, name, resize, flags)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetLowColor(ViewColor());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Does nothing
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFView::~TIFFView()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Draw
|
||||
//
|
||||
// Draws information about the TIFFTranslator to this view.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, not used
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
void
|
||||
TIFFView::Draw(BRect area)
|
||||
{
|
||||
SetFont(be_bold_font);
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
float xbold, ybold;
|
||||
xbold = fh.descent + 1;
|
||||
ybold = fh.ascent + fh.descent * 2 + fh.leading;
|
||||
|
||||
char title[] = "OpenBeOS TIFF Image Translator";
|
||||
DrawString(title, BPoint(xbold, ybold));
|
||||
|
||||
SetFont(be_plain_font);
|
||||
font_height plainh;
|
||||
GetFontHeight(&plainh);
|
||||
float yplain;
|
||||
yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;
|
||||
|
||||
char detail[100];
|
||||
sprintf(detail, "Version %d.%d.%d %s",
|
||||
TIFF_TRANSLATOR_VERSION / 100, (TIFF_TRANSLATOR_VERSION / 10) % 10,
|
||||
TIFF_TRANSLATOR_VERSION % 10, __DATE__);
|
||||
DrawString(detail, BPoint(xbold, yplain + ybold));
|
||||
/* char copyright[] = "© 2003 OpenBeOS Project";
|
||||
DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));
|
||||
*/
|
||||
char writtenby[] = "Written by the OBOS Translation Kit Team";
|
||||
DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFView.h
|
||||
//
|
||||
// This BView based object displays information about the TIFFTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFFVIEW_H
|
||||
#define TIFFVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
class TIFFView : public BView {
|
||||
public:
|
||||
TIFFView(const BRect &frame, const char *name, uint32 resize,
|
||||
uint32 flags);
|
||||
// sets up the view
|
||||
|
||||
~TIFFView();
|
||||
// does nothing
|
||||
|
||||
virtual void Draw(BRect area);
|
||||
// draws information about the TIFFTranslator
|
||||
};
|
||||
|
||||
#endif // #ifndef TIFFVIEW_H
|
@ -1,69 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFWindow.cpp
|
||||
//
|
||||
// This BWindow based object is used to hold the TIFFView object when the
|
||||
// user runs the TIFFTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "TIFFWindow.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the BWindow for holding a TIFFView
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, The bounds of the window
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFWindow::TIFFWindow(BRect area)
|
||||
: BWindow(area, "TIFFTranslator", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Posts a quit message so that the application is close properly
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFWindow::~TIFFWindow()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFWindow.h
|
||||
//
|
||||
// This BWindow based object is used to hold the TIFFView object when the
|
||||
// user runs the TIFFTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFFWINDOW_H
|
||||
#define TIFFWINDOW_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
class TIFFWindow : public BWindow {
|
||||
public:
|
||||
TIFFWindow(BRect area);
|
||||
// Sets up a BWindow with bounds area
|
||||
|
||||
~TIFFWindow();
|
||||
// Posts a quit message so that the application closes properly
|
||||
};
|
||||
|
||||
#endif // #define TIFFWINDOW_H
|
@ -1,42 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffField.cpp
|
||||
//
|
||||
// This object is for storing TIFF fields
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <Errors.h>
|
||||
#include "TiffField.h"
|
||||
|
||||
TiffField::TiffField(IFDEntry &entry)
|
||||
{
|
||||
finitStatus = B_ERROR;
|
||||
// responsibility of derived class to set this properly
|
||||
|
||||
ftag = entry.tag;
|
||||
ffieldType = entry.fieldType;
|
||||
fcount = entry.count;
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffField.h
|
||||
//
|
||||
// This object is for storing TIFF fields
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_FIELD_H
|
||||
#define TIFF_FIELD_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// TIFF field id numbers for fields that the
|
||||
// TIFFTranslator needs to know about / use
|
||||
// (not a complete list of all tags)
|
||||
#define TAG_NEW_SUBFILE_TYPE 254
|
||||
#define NEW_SUBFILE_TYPE_REDUCED 1
|
||||
#define NEW_SUBFILE_TYPE_PAGE 2
|
||||
#define NEW_SUBFILE_TYPE_MASK 4
|
||||
#define TAG_SUBFILE_TYPE 255
|
||||
#define SUBFILE_TYPE_FULL 1
|
||||
#define SUBFILE_TYPE_REDUCED 2
|
||||
#define SUBFILE_TYPE_PAGE 3
|
||||
#define TAG_IMAGE_WIDTH 256
|
||||
#define TAG_IMAGE_HEIGHT 257
|
||||
#define TAG_BITS_PER_SAMPLE 258
|
||||
#define TAG_COMPRESSION 259
|
||||
#define COMPRESSION_NONE 1
|
||||
#define COMPRESSION_HUFFMAN 2
|
||||
#define COMPRESSION_T4 3
|
||||
#define COMPRESSION_T6 4
|
||||
#define COMPRESSION_LZW 5
|
||||
#define COMPRESSION_JPEG 6
|
||||
#define COMPRESSION_PACKBITS 32773
|
||||
#define TAG_PHOTO_INTERPRETATION 262
|
||||
#define PHOTO_WHITEZERO 0
|
||||
#define PHOTO_BLACKZERO 1
|
||||
#define PHOTO_RGB 2
|
||||
#define PHOTO_PALETTE 3
|
||||
#define PHOTO_MASK 4
|
||||
#define PHOTO_SEPARATED 5
|
||||
#define TAG_FILL_ORDER 266
|
||||
#define TAG_STRIP_OFFSETS 273
|
||||
#define TAG_ORIENTATION 274
|
||||
#define TAG_SAMPLES_PER_PIXEL 277
|
||||
#define TAG_ROWS_PER_STRIP 278
|
||||
#define DEFAULT_ROWS_PER_STRIP 4294967295UL
|
||||
#define TAG_STRIP_BYTE_COUNTS 279
|
||||
#define TAG_PLANAR_CONFIGURATION 284
|
||||
#define TAG_T4_OPTIONS 292
|
||||
// (Also called Group3Options)
|
||||
#define T4_2D 1
|
||||
#define T4_UNCOMPRESSED 2
|
||||
#define T4_FILL_BYTE_BOUNDARY 4
|
||||
#define TAG_T6_OPTIONS 293
|
||||
// (Also called Group4Options)
|
||||
#define TAG_RESOLUTION_UNIT 296
|
||||
#define TAG_COLOR_MAP 320
|
||||
#define TAG_INK_SET 332
|
||||
#define INK_SET_CMYK 1
|
||||
#define INK_SET_NOT_CMYK 2
|
||||
#define TAG_EXTRA_SAMPLES 338
|
||||
#define TAG_SAMPLE_FORMAT 339
|
||||
|
||||
// Some types of data that can
|
||||
// exist in a TIFF field
|
||||
enum TIFF_ENTRY_TYPE {
|
||||
TIFF_BYTE = 1,
|
||||
TIFF_ASCII,
|
||||
TIFF_SHORT,
|
||||
TIFF_LONG,
|
||||
TIFF_RATIONAL,
|
||||
TIFF_SBYTE,
|
||||
TIFF_UNDEFINED,
|
||||
TIFF_SSHORT,
|
||||
TIFF_SRATIONAL,
|
||||
TIFF_FLOAT,
|
||||
TIFF_DOUBLE
|
||||
};
|
||||
|
||||
struct IFDEntry {
|
||||
uint16 tag;
|
||||
// uniquely identifies the field
|
||||
uint16 fieldType;
|
||||
// number, string, float, etc.
|
||||
uint32 count;
|
||||
// length / number of values
|
||||
|
||||
// The actual value or the file offset
|
||||
// where the actual value is located
|
||||
union {
|
||||
float floatval;
|
||||
uint32 longval;
|
||||
uint16 shortvals[2];
|
||||
uint8 bytevals[4];
|
||||
};
|
||||
};
|
||||
|
||||
class TiffField {
|
||||
public:
|
||||
TiffField(IFDEntry &entry);
|
||||
virtual ~TiffField() {};
|
||||
|
||||
status_t InitCheck() { return finitStatus; };
|
||||
uint16 GetTag() { return ftag; };
|
||||
uint16 GetType() { return ffieldType; };
|
||||
uint32 GetCount() { return fcount; };
|
||||
|
||||
protected:
|
||||
status_t finitStatus;
|
||||
|
||||
private:
|
||||
uint16 ftag;
|
||||
uint16 ffieldType;
|
||||
uint32 fcount;
|
||||
};
|
||||
|
||||
#endif // #define TIFF_FIELD_H
|
@ -1,273 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffIfd
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffIfd.cpp
|
||||
//
|
||||
// This object is for storing a TIFF Image File Directory
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "TiffIfd.h"
|
||||
#include "TiffUintField.h"
|
||||
#include "TiffUnknownField.h"
|
||||
|
||||
void
|
||||
TiffIfd::LoadFields(uint32 offset, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
if (io.ReadAt(offset, &ffieldCount, 2) != 2) {
|
||||
finitStatus = B_IO_ERROR;
|
||||
return;
|
||||
} else {
|
||||
if (swap_data(B_UINT16_TYPE, &ffieldCount, 2, swp) != B_OK) {
|
||||
finitStatus = B_ERROR;
|
||||
return;
|
||||
} else {
|
||||
fpfields = new TiffField *[ffieldCount];
|
||||
if (!fpfields) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
} else {
|
||||
memset(fpfields, 0, ffieldCount * sizeof(TiffField *));
|
||||
// set all pointers to TiffFields to NULL
|
||||
|
||||
// Load TIFF IFD Entries
|
||||
offset += 2;
|
||||
uint16 i;
|
||||
finitStatus = B_OK;
|
||||
for (i = 0; i < ffieldCount; i++, offset += 12) {
|
||||
IFDEntry entry;
|
||||
|
||||
if (io.ReadAt(offset, &entry, 12) != 12) {
|
||||
finitStatus = B_IO_ERROR;
|
||||
return;
|
||||
}
|
||||
if (swap_data(B_UINT16_TYPE, &entry.tag, 2, swp) != B_OK) {
|
||||
finitStatus = B_ERROR;
|
||||
return;
|
||||
}
|
||||
if (swap_data(B_UINT16_TYPE, &entry.fieldType, 2, swp) != B_OK) {
|
||||
finitStatus = B_ERROR;
|
||||
return;
|
||||
}
|
||||
if (swap_data(B_UINT32_TYPE, &entry.count, 4, swp) != B_OK) {
|
||||
finitStatus = B_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a TiffField based object to store the
|
||||
// TIFF entry
|
||||
switch (entry.fieldType) {
|
||||
case TIFF_BYTE:
|
||||
case TIFF_SHORT:
|
||||
case TIFF_LONG:
|
||||
fpfields[i] = new TiffUintField(entry, io, swp);
|
||||
break;
|
||||
|
||||
default:
|
||||
fpfields[i] = new TiffUnknownField(entry);
|
||||
break;
|
||||
}
|
||||
if (!fpfields[i]) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
if (fpfields[i]->InitCheck() != B_OK) {
|
||||
finitStatus = fpfields[i]->InitCheck();
|
||||
return;
|
||||
}
|
||||
} // for (i = 0; i < ffieldCount; i++, offset += 12)
|
||||
|
||||
// Read address of next IFD entry
|
||||
if (io.ReadAt(offset, &fnextIFDOffset, 4) != 4) {
|
||||
finitStatus = B_IO_ERROR;
|
||||
return;
|
||||
}
|
||||
if (swap_data(B_UINT32_TYPE, &fnextIFDOffset, 4, swp) != B_OK) {
|
||||
finitStatus = B_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TiffIfd::TiffIfd(uint32 offset, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
fpfields = NULL;
|
||||
finitStatus = B_ERROR;
|
||||
fnextIFDOffset = 0;
|
||||
ffieldCount = 0;
|
||||
|
||||
LoadFields(offset, io, swp);
|
||||
}
|
||||
|
||||
TiffIfd::~TiffIfd()
|
||||
{
|
||||
for (uint16 i = 0; i < ffieldCount; i++) {
|
||||
delete fpfields[i];
|
||||
fpfields[i] = NULL;
|
||||
}
|
||||
delete[] fpfields;
|
||||
fpfields = NULL;
|
||||
|
||||
ffieldCount = 0;
|
||||
fnextIFDOffset = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
TiffIfd::HasField(uint16 tag)
|
||||
{
|
||||
TiffField *pfield = GetField(tag);
|
||||
if (pfield)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32
|
||||
TiffIfd::GetCount(uint16 tag)
|
||||
{
|
||||
TiffField *pfield = GetField(tag);
|
||||
if (pfield)
|
||||
return pfield->GetCount();
|
||||
else
|
||||
throw TiffIfdFieldNotFoundException();
|
||||
}
|
||||
|
||||
uint32
|
||||
TiffIfd::GetUint(uint16 tag, uint32 index)
|
||||
{
|
||||
TiffField *pfield = GetField(tag);
|
||||
if (pfield) {
|
||||
|
||||
TiffUintField *puintField = NULL;
|
||||
puintField = dynamic_cast<TiffUintField *>(pfield);
|
||||
if (puintField) {
|
||||
|
||||
uint32 num;
|
||||
status_t ret = puintField->GetUint(num, index);
|
||||
if (ret == B_OK)
|
||||
return num;
|
||||
else if (ret == B_BAD_INDEX)
|
||||
throw TiffIfdBadIndexException();
|
||||
else
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
|
||||
} else
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
}
|
||||
|
||||
throw TiffIfdFieldNotFoundException();
|
||||
}
|
||||
|
||||
uint32
|
||||
TiffIfd::GetAdjustedColorMap(uint8 **pout)
|
||||
{
|
||||
TiffField *pfield = GetField(TAG_COLOR_MAP);
|
||||
if (pfield) {
|
||||
|
||||
TiffUintField *puintField = NULL;
|
||||
puintField = dynamic_cast<TiffUintField *>(pfield);
|
||||
if (puintField) {
|
||||
|
||||
uint32 count = puintField->GetCount();
|
||||
(*pout) = new uint8[count];
|
||||
uint8 *puints = (*pout);
|
||||
if (!puints)
|
||||
throw TiffIfdNoMemoryException();
|
||||
|
||||
for (uint32 i = 0; i < count; i++) {
|
||||
uint32 num;
|
||||
status_t ret = puintField->GetUint(num, i + 1);
|
||||
if (ret == B_BAD_INDEX)
|
||||
throw TiffIfdBadIndexException();
|
||||
else if (ret == B_BAD_TYPE)
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
|
||||
puints[i] = num / 256;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
} else
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
}
|
||||
|
||||
throw TiffIfdFieldNotFoundException();
|
||||
}
|
||||
|
||||
uint32
|
||||
TiffIfd::GetUint32Array(uint16 tag, uint32 **pout)
|
||||
{
|
||||
TiffField *pfield = GetField(tag);
|
||||
if (pfield) {
|
||||
|
||||
TiffUintField *puintField = NULL;
|
||||
puintField = dynamic_cast<TiffUintField *>(pfield);
|
||||
if (puintField) {
|
||||
|
||||
uint32 count = puintField->GetCount();
|
||||
(*pout) = new uint32[count];
|
||||
uint32 *puints = (*pout);
|
||||
if (!puints)
|
||||
throw TiffIfdNoMemoryException();
|
||||
|
||||
for (uint32 i = 0; i < count; i++) {
|
||||
uint32 num;
|
||||
status_t ret = puintField->GetUint(num, i + 1);
|
||||
if (ret == B_BAD_INDEX)
|
||||
throw TiffIfdBadIndexException();
|
||||
else if (ret == B_BAD_TYPE)
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
|
||||
puints[i] = num;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
} else
|
||||
throw TiffIfdUnexpectedTypeException();
|
||||
}
|
||||
|
||||
throw TiffIfdFieldNotFoundException();
|
||||
}
|
||||
|
||||
TiffField *
|
||||
TiffIfd::GetField(uint16 tag)
|
||||
{
|
||||
for (uint16 i = 0; i < ffieldCount; i++) {
|
||||
TiffField *pfield = fpfields[i];
|
||||
if (pfield) {
|
||||
uint16 ltag = pfield->GetTag();
|
||||
if (tag == ltag)
|
||||
return pfield;
|
||||
else if (ltag > tag)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffIfd
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffIfd.h
|
||||
//
|
||||
// This object is for storing a TIFF Image File Directory
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_IFD_H
|
||||
#define TIFF_IFD_H
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <DataIO.h>
|
||||
#include "TiffField.h"
|
||||
#include "TiffUintField.h"
|
||||
|
||||
class TiffIfdException {
|
||||
public:
|
||||
TiffIfdException() { };
|
||||
};
|
||||
class TiffIfdFieldNotFoundException : public TiffIfdException {
|
||||
public:
|
||||
TiffIfdFieldNotFoundException() { };
|
||||
};
|
||||
class TiffIfdUnexpectedTypeException : public TiffIfdException {
|
||||
public:
|
||||
TiffIfdUnexpectedTypeException() { };
|
||||
};
|
||||
class TiffIfdBadIndexException : public TiffIfdException {
|
||||
public:
|
||||
TiffIfdBadIndexException() { };
|
||||
};
|
||||
class TiffIfdNoMemoryException : public TiffIfdException {
|
||||
public:
|
||||
TiffIfdNoMemoryException() { };
|
||||
};
|
||||
|
||||
class TiffIfd {
|
||||
public:
|
||||
TiffIfd(uint32 offset, BPositionIO &io, swap_action swp);
|
||||
~TiffIfd();
|
||||
status_t InitCheck() { return finitStatus; };
|
||||
|
||||
bool HasField(uint16 tag);
|
||||
uint32 GetCount(uint16 tag);
|
||||
// throws: TiffIfdFieldNotFoundException()
|
||||
|
||||
uint32 GetNextIfdOffset() { return fnextIFDOffset; };
|
||||
|
||||
uint32 GetUint(uint16 tag, uint32 index = 0);
|
||||
// index is the base one index for the desired
|
||||
// number in the specified field. When index is the default
|
||||
// value of zero: if the count is one, the
|
||||
// first number will be returned, if it is not
|
||||
// one, TiffIfdBadIndexException() will be thrown
|
||||
//
|
||||
// throws: TiffIfdFieldNotFoundException(),
|
||||
// TiffIfdUnexpectedTypeException(),
|
||||
// TiffIfdBadIndexException()
|
||||
|
||||
uint32 GetAdjustedColorMap(uint8 **pout);
|
||||
uint32 GetUint32Array(uint16 tag, uint32 **pout);
|
||||
// copies all of the uints from tag to
|
||||
// the pointer pointed to by pout
|
||||
// and returns the number of uints copied
|
||||
//
|
||||
// throws: TiffIfdFieldNotFoundException(),
|
||||
// TiffIfdUnexpectedTypeException(),
|
||||
// TiffIfdBadIndexException()
|
||||
// TiffIfdNoMemoryException()
|
||||
|
||||
private:
|
||||
void LoadFields(uint32 offset, BPositionIO &io, swap_action swp);
|
||||
TiffField *GetField(uint16 tag);
|
||||
|
||||
TiffField **fpfields;
|
||||
status_t finitStatus;
|
||||
uint32 fnextIFDOffset;
|
||||
uint16 ffieldCount;
|
||||
};
|
||||
|
||||
#endif // TIFF_IFD_H
|
@ -1,120 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffIfdList
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffIfdList.cpp
|
||||
//
|
||||
// This object is for storing all IFD entries from a TIFF file
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "TiffIfdList.h"
|
||||
|
||||
status_t
|
||||
TiffIfdList::LoadIfds(uint32 offset, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
Empty();
|
||||
|
||||
TiffIfdNode *pnode = NULL;
|
||||
while (offset) {
|
||||
// Create new node at the end of the list
|
||||
if (!fpfirst) {
|
||||
fpfirst = new TiffIfdNode;
|
||||
pnode = fpfirst;
|
||||
} else {
|
||||
pnode->pnext = new TiffIfdNode;
|
||||
pnode = pnode->pnext;
|
||||
}
|
||||
if (!pnode) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
// Create new TiffIfd and check its status
|
||||
pnode->pnext = NULL;
|
||||
pnode->pifd = new TiffIfd(offset, io, swp);
|
||||
if (!pnode->pifd) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
break;
|
||||
}
|
||||
if (pnode->pifd->InitCheck() != B_OK) {
|
||||
finitStatus = pnode->pifd->InitCheck();
|
||||
break;
|
||||
}
|
||||
|
||||
offset = pnode->pifd->GetNextIfdOffset();
|
||||
fcount++;
|
||||
}
|
||||
|
||||
if (finitStatus != B_OK)
|
||||
fcount = 0;
|
||||
|
||||
return finitStatus;
|
||||
}
|
||||
|
||||
TiffIfdList::TiffIfdList(uint32 offset, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
fpfirst = NULL;
|
||||
finitStatus = B_OK;
|
||||
fcount = 0;
|
||||
|
||||
LoadIfds(offset, io, swp);
|
||||
}
|
||||
|
||||
TiffIfdList::~TiffIfdList()
|
||||
{
|
||||
Empty();
|
||||
}
|
||||
|
||||
void
|
||||
TiffIfdList::Empty()
|
||||
{
|
||||
TiffIfdNode *pnode, *pdelme;
|
||||
pnode = fpfirst;
|
||||
|
||||
while (pnode) {
|
||||
pdelme = pnode;
|
||||
pnode = pnode->pnext;
|
||||
|
||||
delete pdelme->pifd;
|
||||
delete pdelme;
|
||||
}
|
||||
fpfirst = NULL;
|
||||
fcount = 0;
|
||||
finitStatus = B_OK;
|
||||
}
|
||||
|
||||
// index is zero based
|
||||
TiffIfd *
|
||||
TiffIfdList::GetIfd(int32 index)
|
||||
{
|
||||
if (index < 0 || index >= fcount)
|
||||
return NULL;
|
||||
|
||||
TiffIfdNode *pnode = fpfirst;
|
||||
while (index--)
|
||||
pnode = pnode->pnext;
|
||||
|
||||
return pnode->pifd;
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffIfdList
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffIfdList.h
|
||||
//
|
||||
// This object is for storing all IFD entries from a TIFF file
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_IFD_LIST_H
|
||||
#define TIFF_IFD_LIST_H
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <DataIO.h>
|
||||
#include "TiffIfd.h"
|
||||
|
||||
struct TiffIfdNode {
|
||||
TiffIfd *pifd;
|
||||
TiffIfdNode *pnext;
|
||||
};
|
||||
|
||||
class TiffIfdList {
|
||||
public:
|
||||
TiffIfdList(uint32 offset, BPositionIO &io, swap_action swp);
|
||||
~TiffIfdList();
|
||||
status_t InitCheck() { return finitStatus; };
|
||||
|
||||
status_t LoadIfds(uint32 offset, BPositionIO &io, swap_action swp);
|
||||
void Empty();
|
||||
|
||||
int32 GetCount() { return fcount; };
|
||||
TiffIfd *GetIfd(int32 index);
|
||||
// index is zero based
|
||||
|
||||
private:
|
||||
status_t finitStatus;
|
||||
TiffIfdNode *fpfirst;
|
||||
int32 fcount;
|
||||
};
|
||||
|
||||
#endif // #ifndef TIFF_IFD_LIST_H
|
@ -1,257 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffUintField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffUintField.cpp
|
||||
//
|
||||
// This object is for storing Unsigned Integer TIFF fields
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "TiffUintField.h"
|
||||
|
||||
void
|
||||
TiffUintField::LoadByte(IFDEntry &entry, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
// Make certain there is enough memory
|
||||
// before trying to do anything else
|
||||
fpByte = new uint8[entry.count];
|
||||
if (!fpByte) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.count <= 4) {
|
||||
// If all of the byte values can fit into the
|
||||
// IFD entry value bytes
|
||||
memcpy(fpByte, entry.bytevals, entry.count);
|
||||
finitStatus = B_OK;
|
||||
} else {
|
||||
|
||||
// entry.count > 4, use longval to find offset for byte data
|
||||
if (swap_data(B_UINT32_TYPE, &entry.longval, 4, swp) != B_OK)
|
||||
finitStatus = B_ERROR;
|
||||
else {
|
||||
ssize_t read;
|
||||
read = io.ReadAt(entry.longval, fpByte, entry.count);
|
||||
if (read != static_cast<ssize_t>(entry.count))
|
||||
finitStatus = B_IO_ERROR;
|
||||
else
|
||||
finitStatus = B_OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TiffUintField::LoadShort(IFDEntry &entry, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
// Make certain there is enough memory
|
||||
// before trying to do anything else
|
||||
fpShort = new uint16[entry.count];
|
||||
if (!fpShort) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.count <= 2) {
|
||||
// If all of the byte values can fit into the
|
||||
// IFD entry value bytes
|
||||
memcpy(fpShort, entry.shortvals, entry.count * 2);
|
||||
finitStatus = B_OK;
|
||||
} else {
|
||||
|
||||
// entry.count > 2, use longval to find offset for short data
|
||||
if (swap_data(B_UINT32_TYPE, &entry.longval, 4, swp) != B_OK)
|
||||
finitStatus = B_ERROR;
|
||||
else {
|
||||
ssize_t read;
|
||||
read = io.ReadAt(entry.longval, fpShort, entry.count * 2);
|
||||
if (read != static_cast<ssize_t>(entry.count) * 2)
|
||||
finitStatus = B_IO_ERROR;
|
||||
else
|
||||
finitStatus = B_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If short values were successfully read in, swap them to
|
||||
// the correct byte order
|
||||
if (finitStatus == B_OK &&
|
||||
swap_data(B_UINT16_TYPE, fpShort, entry.count * 2, swp) != B_OK)
|
||||
finitStatus = B_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
TiffUintField::LoadLong(IFDEntry &entry, BPositionIO &io, swap_action swp)
|
||||
{
|
||||
// Make certain there is enough memory
|
||||
// before trying to do anything else
|
||||
fpLong = new uint32[entry.count];
|
||||
if (!fpLong) {
|
||||
finitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.count == 1) {
|
||||
fpLong[0] = entry.longval;
|
||||
finitStatus = B_OK;
|
||||
} else {
|
||||
|
||||
// entry.count > 1, use longval to find offset for long data
|
||||
if (swap_data(B_UINT32_TYPE, &entry.longval, 4, swp) != B_OK)
|
||||
finitStatus = B_ERROR;
|
||||
else {
|
||||
ssize_t read;
|
||||
read = io.ReadAt(entry.longval, fpLong, entry.count * 4);
|
||||
if (read != static_cast<ssize_t>(entry.count) * 4)
|
||||
finitStatus = B_IO_ERROR;
|
||||
else
|
||||
finitStatus = B_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If long values were successfully read in, swap them to
|
||||
// the correct byte order
|
||||
if (finitStatus == B_OK &&
|
||||
swap_data(B_UINT32_TYPE, fpLong, entry.count * 4, swp) != B_OK)
|
||||
finitStatus = B_ERROR;
|
||||
}
|
||||
|
||||
TiffUintField::TiffUintField(IFDEntry &entry, BPositionIO &io, swap_action swp)
|
||||
: TiffField(entry)
|
||||
{
|
||||
if (entry.count > 0) {
|
||||
switch (entry.fieldType) {
|
||||
case TIFF_BYTE:
|
||||
fpByte = NULL;
|
||||
LoadByte(entry, io, swp);
|
||||
break;
|
||||
|
||||
case TIFF_SHORT:
|
||||
fpShort = NULL;
|
||||
LoadShort(entry, io, swp);
|
||||
break;
|
||||
|
||||
case TIFF_LONG:
|
||||
fpLong = NULL;
|
||||
LoadLong(entry, io, swp);
|
||||
break;
|
||||
|
||||
default:
|
||||
finitStatus = B_BAD_TYPE;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
finitStatus = B_BAD_VALUE;
|
||||
}
|
||||
|
||||
TiffUintField::~TiffUintField()
|
||||
{
|
||||
switch (GetType()) {
|
||||
case TIFF_BYTE:
|
||||
delete[] fpByte;
|
||||
fpByte = NULL;
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
delete[] fpShort;
|
||||
fpShort = NULL;
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
delete[] fpLong;
|
||||
fpLong = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
// if invalid type, should have never
|
||||
// allocated any value, so there should
|
||||
// be no value to delete
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// GetUint
|
||||
//
|
||||
// Retrieves the number at the given index for this field.
|
||||
// Some fields store a single number, others store an array of
|
||||
// numbers.
|
||||
//
|
||||
// The index parameter has a default value of zero. When
|
||||
// index is zero, there is special behavior: the first
|
||||
// number is retrieved if this field has a count of 1. If
|
||||
// the index is zero and the field's count is not 1, then
|
||||
// B_BAD_INDEX will be returned.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: out, where the desired uint is copied to
|
||||
//
|
||||
// index, one-based index for the desired value
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: B_OK if the field was found and it is a TiffUintField
|
||||
// based object,
|
||||
//
|
||||
// B_BAD_TYPE if the field was found BUT it was not a
|
||||
// TiffUintField based object
|
||||
//
|
||||
// B_BAD_INDEX if a field with the given tag
|
||||
// was not found
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
TiffUintField::GetUint(uint32 &out, uint32 index)
|
||||
{
|
||||
if (finitStatus != B_OK)
|
||||
return finitStatus;
|
||||
|
||||
uint32 count = GetCount();
|
||||
if (index > count || (index == 0 && count != 1))
|
||||
return B_BAD_INDEX;
|
||||
|
||||
status_t result = B_OK;
|
||||
if (!index)
|
||||
index = 1;
|
||||
switch (GetType()) {
|
||||
case TIFF_BYTE:
|
||||
out = fpByte[index - 1];
|
||||
break;
|
||||
|
||||
case TIFF_SHORT:
|
||||
out = fpShort[index - 1];
|
||||
break;
|
||||
|
||||
case TIFF_LONG:
|
||||
out = fpLong[index - 1];
|
||||
break;
|
||||
|
||||
default:
|
||||
result = B_BAD_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffUintField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffUintField.h
|
||||
//
|
||||
// This object is for storing Unsigned Integer TIFF fields
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_UNIT_FIELD_H
|
||||
#define TIFF_UNIT_FIELD_H
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <ByteOrder.h>
|
||||
#include "TiffField.h"
|
||||
|
||||
class TiffUintField : public TiffField {
|
||||
public:
|
||||
TiffUintField(IFDEntry &entry, BPositionIO &io, swap_action swp);
|
||||
virtual ~TiffUintField();
|
||||
|
||||
status_t GetUint(uint32 &out, uint32 index = 0);
|
||||
|
||||
private:
|
||||
void LoadByte(IFDEntry &entry, BPositionIO &io, swap_action swp);
|
||||
void LoadShort(IFDEntry &entry, BPositionIO &io, swap_action swp);
|
||||
void LoadLong(IFDEntry &entry, BPositionIO &io, swap_action swp);
|
||||
|
||||
union {
|
||||
uint8 *fpByte;
|
||||
uint16 *fpShort;
|
||||
uint32 *fpLong;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // #define TIFF_UNIT_FIELD_H
|
@ -1,42 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffUnknownField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffUnknownField.cpp
|
||||
//
|
||||
// This object is for storing TIFF fields that the translator doesn't know
|
||||
// or doesn't care about
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "TiffUnknownField.h"
|
||||
|
||||
TiffUnknownField::TiffUnknownField(IFDEntry &entry)
|
||||
: TiffField(entry)
|
||||
{
|
||||
finitStatus = B_OK;
|
||||
}
|
||||
|
||||
TiffUnknownField::~TiffUnknownField()
|
||||
{
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// TiffUnknownField
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TiffUnknownField.h
|
||||
//
|
||||
// This object is for storing TIFF fields that the translator doesn't know
|
||||
// or doesn't care about
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_UNKNOWN_FIELD_H
|
||||
#define TIFF_UNKNOWN_FIELD_H
|
||||
|
||||
#include "TiffField.h"
|
||||
|
||||
class TiffUnknownField : public TiffField {
|
||||
public:
|
||||
TiffUnknownField(IFDEntry &entry);
|
||||
virtual ~TiffUnknownField();
|
||||
};
|
||||
|
||||
#endif // TIFF_UNKNOWN_FIELD_H
|
Loading…
Reference in New Issue
Block a user