mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
Use existing image decoders to handle clipboard BMP data.
This gets rid of the old nsImageClipboard widget code in favor of using the nsBMPDecoder in imglib.
This commit is contained in:
parent
84cc1f3239
commit
c15f982d7a
11 changed files with 149 additions and 651 deletions
|
|
@ -185,9 +185,11 @@ nsBMPDecoder::nsBMPDecoder(RasterImage* aImage, State aState, size_t aLength)
|
|||
{
|
||||
}
|
||||
|
||||
// Constructor for normal BMP files.
|
||||
nsBMPDecoder::nsBMPDecoder(RasterImage* aImage)
|
||||
: nsBMPDecoder(aImage, State::FILE_HEADER, FILE_HEADER_LENGTH)
|
||||
// Constructor for normal BMP files or from the clipboard.
|
||||
nsBMPDecoder::nsBMPDecoder(RasterImage* aImage, bool aForClipboard)
|
||||
: nsBMPDecoder(aImage,
|
||||
aForClipboard ? State::CLIPBOARD_HEADER : State::FILE_HEADER,
|
||||
aForClipboard ? BIHSIZE_FIELD_LENGTH : FILE_HEADER_LENGTH)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -455,6 +457,7 @@ nsBMPDecoder::DoDecode(SourceBufferIterator& aIterator, IResumable* aOnResume)
|
|||
[=](State aState, const char* aData, size_t aLength) {
|
||||
switch (aState) {
|
||||
case State::FILE_HEADER: return ReadFileHeader(aData, aLength);
|
||||
case State::CLIPBOARD_HEADER: return ReadClipboardHeader(aData, aLength);
|
||||
case State::INFO_HEADER_SIZE: return ReadInfoHeaderSize(aData, aLength);
|
||||
case State::INFO_HEADER_REST: return ReadInfoHeaderRest(aData, aLength);
|
||||
case State::BITFIELDS: return ReadBitfields(aData, aLength);
|
||||
|
|
@ -488,6 +491,14 @@ nsBMPDecoder::ReadFileHeader(const char* aData, size_t aLength)
|
|||
return Transition::To(State::INFO_HEADER_SIZE, BIHSIZE_FIELD_LENGTH);
|
||||
}
|
||||
|
||||
LexerTransition<nsBMPDecoder::State>
|
||||
nsBMPDecoder::ReadClipboardHeader(const char* aData, size_t aLength)
|
||||
{
|
||||
// With the clipboard, the data offset is the header length.
|
||||
mH.mDataOffset = LittleEndian::readUint32(aData);
|
||||
return ReadInfoHeaderSize(aData, aLength);
|
||||
}
|
||||
|
||||
// We read the info header in two steps: (a) read the mBIHSize field to
|
||||
// determine how long the header is; (b) read the rest of the header.
|
||||
LexerTransition<nsBMPDecoder::State>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue