Exemple #1
0
        /// <summary>
        /// Special row-processing that only stores the alpha data.
        /// </summary>
        public static void ExtractAlphaRows(LosslessDecoder dec, int row)
        {
            int num_rows = row - dec.last_row_;
            if (num_rows <= 0) return;  // Nothing to be done.

            dec.ApplyInverseTransforms (num_rows, dec.pixels32_, dec.width_ * dec.last_row_);

            // Extract alpha (which is stored in the green plane).

            int width = dec.io_.width;      // the final width (!= dec->width_)
            int cache_pixs = width * num_rows;
            //            uint8_t* const dst = (uint8_t*)dec->io_->opaque + width * dec->last_row_;
            int dst = width * dec.last_row_;
            int src = dec.argb_cache_;
            for (int i = 0; i < cache_pixs; ++i)
                dec.io_.opaque[dst+i] = (byte)(dec.pixels32_[src+i] >> 8);
            dec.last_row_ = dec.last_out_row_ = row;
        }
Exemple #2
0
 // Processes (transforms, scales & color-converts) the rows decoded after the
 // last call.
 static void ProcessRows(LosslessDecoder dec, int row)
 {
     throw new NotImplementedException ("Lossless RGB decoder not implemented");
 }
Exemple #3
0
        bool DecodeAlphaHeader(byte[] data, int data_i, int data_size, byte[] output)
        {
            vp8l_dec_ = new LosslessDecoder();
            vp8l_dec_.Init (width_, height_, m_io, data, data_i, data_size, output);

            uint[] decoded = null;
            if (!vp8l_dec_.DecodeImageStream (width_, height_, true, ref decoded, false))
                return false;

            // Special case: if alpha data uses only the color indexing transform and
            // doesn't use color cache (a frequent case), we will use DecodeAlphaData()
            // method that only needs allocation of 1 byte per pixel (alpha channel).
            if (vp8l_dec_.next_transform_ == 1
                && vp8l_dec_.transforms_[0].type_ == VP8LImageTransformType.ColorIndexing
                && vp8l_dec_.Is8bOptimizable())
            {
                use_8b_decode_ = true;
                vp8l_dec_.AllocateInternalBuffers8b();
            }
            else
            {
                // Allocate internal buffers (note that dec->width_ may have changed here).
                use_8b_decode_ = false;
                vp8l_dec_.AllocateInternalBuffers32b (width_);
            }
            return true;
        }