Beispiel #1
0
        public void LoadImage(System.Drawing.Size size)
        {
            CheckDisposedState();
            lock (this)
            {
                if (_itemState == PhotoItemState.Cached)
                {
                    if (size.Width > _image.Width && size.Height > _image.Height)
                    {
                        _image.LoadThumbnail(_hddFileName, (int)size.Width, (int)size.Height);
                        RotateImage();
                    }
                    else
                    {
                        int resultWidth = size.Width, resultHeight = size.Height;
                        Resize.CalculateProportionalDimensions(_image.Width, _image.Height, ref resultWidth, ref resultHeight, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit);
                        if (_image.Width != resultWidth || _image.Height != resultHeight)
                        {
                            _image.Transforms.Resize(resultWidth, resultHeight);
                        }
                    }
                }
                else if (_itemState == PhotoItemState.Empty)
                {
                    _hddFileName = PhotoItem.Cache.CacheSource(this);
                    _image.LoadThumbnail(_hddFileName, (int)size.Width, (int)size.Height);

                    using (IFormatReader formatReader = FormatManager.CreateFormatReader(_hddFileName))
                        using (IFrame frame = formatReader.LoadFrame(0))
                        {
                            _imageSize = new Size(frame.Width, frame.Height);
                        }
                    RotateImage();
                    _itemState = PhotoItemState.Cached;
                }
                else
                {
                    ExecutionEngine.EventLogger.Write("Unknown PhotoItem state");
                }
            }
        }