Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions
nsJPEGDecoder Class Reference

#include <nsJPEGDecoder.h>

Inheritance diagram for nsJPEGDecoder:
Inheritance graph
[legend]
Collaboration diagram for nsJPEGDecoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_IMGIDECODER 
nsJPEGDecoder ()
virtual ~nsJPEGDecoder ()
PRBool FillInput (j_decompress_ptr jd)
void init (in imgILoad aLoad)
 Initalize an image decoder.
void close ()
 Closes the stream.
void flush ()
 Flushes the stream.
unsigned long writeFrom (in nsIInputStream inStr, in unsigned long count)
 Writes data into the stream from an input stream.

Public Attributes

PRUint32 mBytesToSkip
nsCOMPtr< imgIContainermImage
nsCOMPtr< imgILoadmImageLoad
nsCOMPtr< gfxIImageFramemFrame
nsCOMPtr< imgIDecoderObservermObserver
decoder_error_mgr mErr
jstate mState
JSAMPARRAY mSamples
PRUint8mRGBRow
PRInt32 mCompletedPasses
PRInt32 mPasses
int mFillState
JOCTETmBuffer
PRUint32 mBufferLen
PRUint32 mBufferSize
JOCTETmBackBuffer
PRUint32 mBackBufferLen
PRUint32 mBackBufferSize
PRUint32 mBackBufferUnreadLen

Protected Member Functions

int OutputScanlines ()

Detailed Description

Definition at line 85 of file nsJPEGDecoder.h.


Constructor & Destructor Documentation

Definition at line 90 of file nsJPEGDecoder.cpp.

Here is the call graph for this function:

Definition at line 112 of file nsJPEGDecoder.cpp.


Member Function Documentation

void imgIDecoder::close ( ) [inherited]

Closes the stream.

void imgIDecoder::flush ( ) [inherited]

Flushes the stream.

void imgIDecoder::init ( in imgILoad  aLoad) [inherited]

Initalize an image decoder.

Parameters:
aRequestthe request that owns the decoder.
Note:
The decode should QI aLoad to an imgIDecoderObserver and should send decoder notifications to the request. The decoder should always pass NULL as the first two parameters to all of the imgIDecoderObserver APIs.

Definition at line 504 of file nsJPEGDecoder.cpp.

{
  PRUint32 top = mInfo.output_scanline;
  PRBool rv = PR_TRUE;

  while ((mInfo.output_scanline < mInfo.output_height)) {
      JSAMPROW samples;

      /* Request one scanline.  Returns 0 or 1 scanlines. */
      int ns = jpeg_read_scanlines(&mInfo, mSamples, 1);
      
      if (ns != 1) {
        rv = PR_FALSE; /* suspend */
        break;
      }

#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON)
      PRUint8 *ptrOutputBuf = mRGBRow;

      JSAMPLE *j1 = mSamples[0];
      for (PRUint32 i=0;i<mInfo.output_width;++i) {
        ptrOutputBuf[2] = *j1++;
        ptrOutputBuf[1] = *j1++;
        ptrOutputBuf[0] = *j1++;
        ptrOutputBuf += 3;
      }

      samples = mRGBRow;
#elif defined(XP_MAC) || defined(XP_MACOSX)
      PRUint8 *ptrOutputBuf = mRGBRow;

      JSAMPLE *j1 = mSamples[0];
      for (PRUint32 i=0;i<mInfo.output_width;++i) {
        ptrOutputBuf[0] = 0;
        ptrOutputBuf[1] = *j1++;
        ptrOutputBuf[2] = *j1++;
        ptrOutputBuf[3] = *j1++;
        ptrOutputBuf += 4;
      }

      samples = mRGBRow;
#else
      samples = mSamples[0];
#endif

      // Note! row_stride here must match the row_stride in
      // nsJPEGDecoder::WriteFrom
#if defined(XP_MAC) || defined(XP_MACOSX)
      int row_stride = mInfo.output_width * 4;
#else
      int row_stride = mInfo.output_width * 3;
#endif

      PRUint32 bpr;
      mFrame->GetImageBytesPerRow(&bpr);
      mFrame->SetImageData(
        samples,             // data
        row_stride,          // length
        (mInfo.output_scanline-1) * bpr); // offset
  }

  if (top != mInfo.output_scanline) {
      nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top);
      mObserver->OnDataAvailable(nsnull, mFrame, &r);
  }

  return rv;
}

Here is the call graph for this function:

unsigned long imgIDecoder::writeFrom ( in nsIInputStream  inStr,
in unsigned long  count 
) [inherited]

Writes data into the stream from an input stream.

Implementer's note: This method is defined by this interface in order to allow the output stream to efficiently copy the data from the input stream into its internal buffer (if any). If this method was provide as an external facility, a separate char* buffer would need to be used in order to call the output stream's other Write method.

Parameters:
fromStreamthe stream from which the data is read
countthe maximun number of bytes to write
Returns:
aWriteCount out parameter to hold the number of bytes written. if an error occurs, the writecount is undefined

Member Data Documentation

Definition at line 124 of file nsJPEGDecoder.h.

Definition at line 125 of file nsJPEGDecoder.h.

Definition at line 126 of file nsJPEGDecoder.h.

Definition at line 127 of file nsJPEGDecoder.h.

Definition at line 120 of file nsJPEGDecoder.h.

Definition at line 121 of file nsJPEGDecoder.h.

Definition at line 122 of file nsJPEGDecoder.h.

Definition at line 96 of file nsJPEGDecoder.h.

Definition at line 115 of file nsJPEGDecoder.h.

Definition at line 109 of file nsJPEGDecoder.h.

Definition at line 118 of file nsJPEGDecoder.h.

Definition at line 104 of file nsJPEGDecoder.h.

Definition at line 102 of file nsJPEGDecoder.h.

Definition at line 103 of file nsJPEGDecoder.h.

Definition at line 106 of file nsJPEGDecoder.h.

Definition at line 116 of file nsJPEGDecoder.h.

Definition at line 113 of file nsJPEGDecoder.h.

Definition at line 112 of file nsJPEGDecoder.h.

Definition at line 110 of file nsJPEGDecoder.h.


The documentation for this class was generated from the following files: