Ejemplo n.º 1
0
 private void LoadAnimation()
 {
     if (AnimationPath != AnimationPathOld)
     {
         AnimationPathOld = AnimationPath;
         animationConverter.Decode(AnimationPath);
         animationConverter.SetFirstFrame();
         LbResourcePath = AnimationPathOld;
         LbResourceName = LB_Tools.GetFileName(LbResourcePath);
     }
 }
Ejemplo n.º 2
0
        private void LoadImage()
        {
            if (ImagePath != ImagePathOld && ImagePath != "")
            {
                ImagePathOld = ImagePath;

                FileInfo f_info = new FileInfo(ImagePath);
                switch (f_info.Extension)
                {
                case ".bmp":
                    if (f_info.Extension == ".bmp")
                    {
                        Bitmap tempBitmap = new Bitmap(ImagePath);
                        if (tempBitmap.Height > MaxSize.Height || tempBitmap.Width > MaxSize.Width)
                        {
                            bitmap = new Bitmap(MaxSize.Width, MaxSize.Height);
                            Graphics g = Graphics.FromImage(bitmap);
                            g.DrawImage(tempBitmap, new Rectangle(0, 0, MaxSize.Width, MaxSize.Height));
                            tempBitmap.Dispose();
                        }
                        else
                        {
                            bitmap = new Bitmap(tempBitmap);
                            tempBitmap.Dispose();
                        }
                        animationConverter = new AnimationConverter(bitmap);
                        string bma_path = Path.GetDirectoryName(ImagePath) + "\\" + Path.GetFileNameWithoutExtension(ImagePath) + ".bma";
                        if (animationConverter.Encode(bma_path, 0, 0, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default))
                        {
                            LbResourcePath = bma_path;
                            LbResourceName = LB_Tools.GetFileName(LbResourcePath);
                        }
                    }
                    break;

                case ".jpg":
                    Stream            imageStreamSource = new FileStream(ImagePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    JpegBitmapDecoder decoder           = new JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                    BitmapSource      bitmapSource      = decoder.Frames[0];
                    bitmap = BitmapFromSource(bitmapSource);
                    break;

                default:

                    break;
                }
            }
        }
Ejemplo n.º 3
0
 public void SetLBResourcePath(string path)
 {
     LbResourcePath = path;
     LbResourceName = LB_Tools.GetFileName(path);
 }