Beispiel #1
0
            public void     UpdateImages(uint _imageStartIndex, Rectangle[] _contentRectangles, ImageFile[] _images, ImageFile.FILE_FORMAT _compressedFormat)
            {
                int newSize = Mathf.Max(m_images.Length, (int)_imageStartIndex + _images.Length);

                WebPageImagePart[] newImages = new WebPageImagePart[newSize];

                // Copy existing images
                for (uint imageIndex = 0; imageIndex < m_images.Length; imageIndex++)
                {
                    newImages[imageIndex] = m_images[imageIndex];
                }

                // Replace with new images
                for (uint imageIndex = 0; imageIndex < _images.Length; imageIndex++)
                {
                    if (newImages[_imageStartIndex + imageIndex] != null)
                    {
                        newImages[_imageStartIndex + imageIndex].Dispose();                             // We're replacing this image with a new one...
                    }

                    if (_images[imageIndex] == null)
                    {
                        throw new Exception("Invalid image! Fiche web images must not be null!");
                    }

                    try {
                        newImages[_imageStartIndex + imageIndex] = new WebPageImagePart(_contentRectangles[imageIndex], _images[imageIndex], _compressedFormat);
                    } catch (Exception _e) {
                        // Something went wrong!
                        m_owner.Database.AsyncMain_ReportFicheStatus(m_owner, FichesDB.FICHE_REPORT_STATUS.ERROR, "An error occurred while saving a part of the web page image! " + _e.Message);
                    }
                }

                // Replace old array
                m_images = newImages;

                // Notify?
                m_owner.NotifyWebPageImageChanged(this);
            }
Beispiel #2
0
            internal override void  Threaded_LoadContent(BinaryReader _reader, bool _prepareContent)
            {
                try {
                    // Use the "light" regular reader that will initialize the array of images
                    Read(_reader);

//                  if ( m_compressedImages[imageIndex].Length == 0 ) {
//                      // Create an error placeholder
//                      uint	imageWidth = m_images.Length > 0 && m_images[0] != null ? m_images[0].Width : PLACEHOLDER_WIDTH;
//                      m_images[imageIndex] = new ImageFile( imageWidth, (uint) (Mathf.PHI * imageWidth), PIXEL_FORMAT.BGR8, DEFAULT_PROFILE );
//                      m_images[imageIndex].Clear( float4.One );
//                      m_images[imageIndex].DrawLine( new float4( 1, 0, 0, 1 ), new float2( 0, 0 ), new float2( m_images[imageIndex].Width-1, m_images[imageIndex].Height-1 ) );
//                      m_images[imageIndex].DrawLine( new float4( 1, 0, 0, 1 ), new float2( 0, m_images[imageIndex].Height-1 ), new float2( m_images[imageIndex].Width-1, 0 ) );
//                      continue;
//                  }
//
//                  if ( m_images[imageIndex] != null ) {
//                      // Dispose of any existing image first...
//                      m_images[imageIndex].Dispose();
//                      m_images[imageIndex] = null;
//                  }

                    // Read image parts
                    for (int imageIndex = 0; imageIndex < m_images.Length; imageIndex++)
                    {
                        try {
                            m_images[imageIndex] = new WebPageImagePart(_reader, _prepareContent);
                        } catch (Exception _e) {
                            m_images[imageIndex] = null;
                            throw new Exception("Failed to read part " + imageIndex + " of the web image chunk", _e);
                        }
                    }
                } catch (Exception _e) {
                    m_owner.m_database.AsyncMain_LogError("An error occurred while attempting to read image chunk for fiche \"" + m_owner.ToString() + "\": " + _e.Message);
                }
            }