Example #1
0
 public void PickImage(CropOption cropOption)
 {
                 #if UNITY_ANDROID
     pluginClass.CallStatic(
         "PickImage",
         new JsonData(cropOption).ToString()
         );
                 #endif
 }
Example #2
0
 public void PickImage(CropOption cropOption)
 {
                 #if UNITY_IPHONE
     _GalleryPicker_PickImage(
         new SaveOption().FileName,
         new JsonData(cropOption).ToString()
         );
                 #endif
 }
Example #3
0
 public void TakePhoto(SaveOption saveOption, CropOption cropOption)
 {
     lastSaveOption = saveOption;
     lastCropOption = cropOption;
                 #if UNITY_ANDROID
     camClass.CallStatic(
         "TakePhoto",
         new JsonData(saveOption).ToString(),
         new JsonData(cropOption).ToString()
         );
                 #endif
 }
Example #4
0
 public void PickImage(CropOption cropOption)
 {
                 #if UNITY_EDITOR
     isPickingImage = true;
     if (!OpenFile("Pick a JPG file. (Close it for PNG)", Application.dataPath, "jpg"))
     {
         if (!OpenFile("Pick a PNG file.", Application.dataPath, "png"))
         {
             pickerObject.SendMessage("OnImagePicked", GalleryPicker.CancelCode);
         }
     }
                 #endif
 }
Example #5
0
        public void TakePhoto(SaveOption saveOptions, CropOption cropOptions)
        {
            lastSaveOption = saveOptions;
            lastCropOption = cropOptions;

            if (ShoudAlterSaveLocation)
            {
                AlterSaveLocation();
            }

                        #if UNITY_IPHONE
            _NativeCamera_TakePhoto(
                new JsonData(saveOptions).ToString(),
                new JsonData(cropOptions).ToString()
                );
                        #endif
        }
        public static Image ResizeImage(Image OriginalImage, Size NewSize, Image Watermark = null, Image Testmark = null, CropOption CropOption = CropOption.FitInArea)
        {
            Size oSize = default(Size);
            Size nSize = default(Size);
            Bitmap bmp = default(Bitmap);
            Graphics g = default(Graphics);
            Rectangle rect = default(Rectangle);

            oSize = OriginalImage.Size;
            switch (CropOption)
            {
                case CropOption.FitInArea:
                    nSize = ResizeInRatio(oSize, NewSize);
                    break;
                case CropOption.FillTheArea:
                    nSize = NewSize;
                    break;
            }

            bmp = new Bitmap(nSize.Width, nSize.Height);
            g = Graphics.FromImage(bmp);
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.InterpolationMode = InterpolationMode.High;

            switch (CropOption)
            {
                case CropOption.FitInArea:

                    break;
                case CropOption.FillTheArea:
                    float ratio0 = NewSize.Width / NewSize.Height;
                    float ratio1 = OriginalImage.Width / OriginalImage.Height;
                    int W1 = 0;
                    int H1 = 0;
                    int X1 = 0;
                    int Y1 = 0;
                    if (ratio0 > ratio1)
                    {
                        W1 = OriginalImage.Width;
                        H1 = NewSize.Height * OriginalImage.Width / NewSize.Width;
                        X1 = 0;
                        Y1 = 0;
                        // (OriginalImage.Height - H1) / 2
                    }
                    else
                    {
                        W1 = NewSize.Width * OriginalImage.Height / NewSize.Height;
                        H1 = OriginalImage.Height;
                        X1 = (OriginalImage.Width - W1) / 2;
                        Y1 = 0;
                    }
                    OriginalImage = Crop(OriginalImage, W1, H1, X1, Y1);
                    oSize = new Size(OriginalImage.Width, OriginalImage.Height);
                    break;
            }

            rect = new Rectangle(0, 0, nSize.Width, nSize.Height);
            g.DrawImage(OriginalImage, rect, 0, 0, oSize.Width, oSize.Height, GraphicsUnit.Pixel);

            if ((Watermark != null))
            {
                Rectangle watermarkRect = new Rectangle(0, nSize.Height - Watermark.Height, Watermark.Width, Watermark.Height);
                g.DrawImage(Watermark, watermarkRect, 0, 0, Watermark.Width, Watermark.Height, GraphicsUnit.Pixel);
            }

            if ((Testmark != null))
            {
                Rectangle testmarkRect = new Rectangle(nSize.Width - Testmark.Width, 0, Testmark.Width, Testmark.Height);
                g.DrawImage(Testmark, testmarkRect, 0, 0, Testmark.Width, Testmark.Height, GraphicsUnit.Pixel);
            }

            OriginalImage.Dispose();
            return bmp;
        }
Example #7
0
 public void TakePhoto(SaveOption saveOptions, CropOption cropOptions)
 {
     Timer.CreateDelay(delegate() {
         messageTarget.SendMessage("OnPhotoCallback", NativeCamera.EditorCode);
     }, 0.5f).Start();
 }