コード例 #1
0
ファイル: NativeGallery.cs プロジェクト: wrighp/Innkeeper
 public ImageProperties(int width, int height, string mimeType, ImageOrientation orientation)
 {
     this.width       = width;
     this.height      = height;
     this.mimeType    = mimeType;
     this.orientation = orientation;
 }
コード例 #2
0
        private void SetImageMargin(Image image, ImageOrientation orientation)
        {
            int left   = 0;
            int top    = 0;
            int right  = 0;
            int bottom = 0;

            switch (orientation)
            {
            case ImageOrientation.ImageToLeft:
                right = 10;
                break;

            case ImageOrientation.ImageOnTop:
                bottom = 10;
                break;

            case ImageOrientation.ImageToRight:
                left = 10;
                break;

            case ImageOrientation.ImageOnBottom:
                top = 10;
                break;
            }

            image.Margin = new System.Windows.Thickness(left, top, right, bottom);
        }
コード例 #3
0
        /// <summary>
        ///     Sets a margin of 10 between the image and the text.
        /// </summary>
        /// <param name="image">The image to add a margin to.</param>
        /// <param name="orientation">The orientation of the image on the button.</param>
        private static void SetImageMargin(Image image, ImageOrientation orientation)
        {
            const int DefaultMargin = 10;
            var       left          = 0;
            var       top           = 0;
            var       right         = 0;
            var       bottom        = 0;

            switch (orientation)
            {
            case ImageOrientation.ImageToLeft:
                right = DefaultMargin;
                break;

            case ImageOrientation.ImageOnTop:
                bottom = DefaultMargin;
                break;

            case ImageOrientation.ImageToRight:
                left = DefaultMargin;
                break;

            case ImageOrientation.ImageOnBottom:
                top = DefaultMargin;
                break;
            }

            image.Margin = new Thickness(left, top, right, bottom);
        }
コード例 #4
0
        /// <summary>
        /// Sets a margin of 10 between the image and the text.
        /// </summary>
        /// <param name="image">The image to add a margin to.</param>
        /// <param name="orientation">The orientation of the image on the button.</param>
        private static void SetImageMargin(System.Windows.Controls.Image image, ImageOrientation orientation)
        {
            const int defaultMargin = 10;
            int       left          = 0;
            int       top           = 0;
            int       right         = 0;
            int       bottom        = 0;

            switch (orientation)
            {
            case ImageOrientation.ImageToLeft:
                right = defaultMargin;
                break;

            case ImageOrientation.ImageOnTop:
                bottom = defaultMargin;
                break;

            case ImageOrientation.ImageToRight:
                left = defaultMargin;
                break;

            case ImageOrientation.ImageOnBottom:
                top = defaultMargin;
                break;
            }

            image.Margin = new System.Windows.Thickness(left, top, right, bottom);
        }
コード例 #5
0
 public void OrientationSetTest([PexAssumeUnderTest] XmpTag target, ImageOrientation value)
 {
     PexAssume.IsTrue((uint)value >= 1U && (uint)value <= 8U);
     target.Orientation = value;
     PexAssert.AreEqual(target.Orientation, value);
     // TODO: add assertions to method XmpTagTest.OrientationSetTest(XmpTag, ImageOrientation)
 }
コード例 #6
0
ファイル: PixbufUtils.cs プロジェクト: mono/f-spot
		static public ImageOrientation Rotate90 (ImageOrientation orientation)
		{
			orientation = Rotate270 (orientation);
			orientation = Rotate270 (orientation);
			orientation = Rotate270 (orientation);
			return orientation;
		}
コード例 #7
0
        void executeRequestForResource(PictureAd ad, ImageOrientation imageOrientation, ImageType imageType)
        {
            string filePath = ad.getLocalImageURL(imageOrientation, imageType);

            if (System.IO.File.Exists(filePath))
            {
                downloadedResourcesCount++;
                if (downloadedResourcesCount == PictureAd.expectedResourcesCount)
                {
                    _resourcesAvailable();
                    _operationCompleteDelegate();
                }
                return;
            }
            string      url = ad.getRemoteImageURL(imageOrientation, imageType);
            HTTPRequest pictureURLRequest = new HTTPRequest(url);

            pictureURLRequest.execute(pictureURLRequestResponse => {
                downloadedResourcesCount++;
                if (pictureURLRequestResponse.dataLength != 0)
                {
                    System.IO.File.WriteAllBytes(ad.getLocalImageURL(imageOrientation, imageType), pictureURLRequestResponse.data);
                }

                if (downloadedResourcesCount == PictureAd.expectedResourcesCount)
                {
                    _resourcesAvailable();
                    _operationCompleteDelegate();
                }
            });
        }
コード例 #8
0
ファイル: IImageFile.cs プロジェクト: cizma/f-spot
 protected virtual void ExtractMetadata(TagLib.Image.File metadata)
 {
     if (metadata != null)
     {
         Orientation = metadata.ImageTag.Orientation;
     }
 }
コード例 #9
0
        /// <summary>
        ///   Sets a margin of 10 between the image and the text.
        /// </summary>
        /// <param name="image">The image to add a margin to.</param>
        /// <param name="orientation">The orientation of the image on the button.</param>
        private void SetImageMargin(Image image, ImageOrientation orientation)
        {
            const int defaultMargin = 10;
            var       left          = 0;
            var       top           = 0;
            var       right         = 0;
            var       bottom        = 0;

            //If the button has text add a margin
            if (!string.IsNullOrEmpty(sourceButton.Text))
            {
                switch (orientation)
                {
                case ImageOrientation.ImageToLeft:
                    right = defaultMargin;
                    break;

                case ImageOrientation.ImageOnTop:
                    bottom = defaultMargin;
                    break;

                case ImageOrientation.ImageToRight:
                    left = defaultMargin;
                    break;

                case ImageOrientation.ImageOnBottom:
                    top = defaultMargin;
                    break;
                }
            }

            image.Margin = new Thickness(left, top, right, bottom);
        }
コード例 #10
0
        public static RotateFlipType GetNormalizationRotation(this ImageOrientation imageOrientation)
        {
            switch (imageOrientation)
            {
            case ImageOrientation.TopLeft:
                break;

            case ImageOrientation.TopRight:
                return(RotateFlipType.RotateNoneFlipX);

            case ImageOrientation.BottomRight:
                return(RotateFlipType.Rotate180FlipNone);

            case ImageOrientation.BottomLeft:
                return(RotateFlipType.Rotate180FlipX);

            case ImageOrientation.LeftTop:
                return(RotateFlipType.Rotate90FlipX);

            case ImageOrientation.RightTop:
                return(RotateFlipType.Rotate90FlipNone);

            case ImageOrientation.RightBottom:
                return(RotateFlipType.Rotate270FlipX);

            case ImageOrientation.LeftBottom:
                return(RotateFlipType.Rotate270FlipNone);
            }

            return(RotateFlipType.RotateNoneFlipNone);
        }
コード例 #11
0
        public static void RotateBitmap(ImageOrientation orientation, ref Bitmap image)
        {
            var matrix = new Matrix();

            // var scaleWidth = ((float)width) / image.Width;
            // var scaleHeight = ((float)height) / image.Height;
            // matrix.PostRotate(90);
            // matrix.PreScale(scaleWidth, scaleHeight);

            switch (orientation)
            {
            case ImageOrientation.Portrait:
                matrix.PostRotate(90);
                break;

            case ImageOrientation.LandscapeLeft:
                //matrix.PostRotate(90);
                break;

            case ImageOrientation.LandscapeRight:
                matrix.PostRotate(180);
                break;

            case ImageOrientation.PortraitBottom:
                matrix.PostRotate(270);
                break;

            default:
                break;
            }

            image = Bitmap.CreateBitmap(image, 0, 0, image.Width, image.Height, matrix, true);
        }
コード例 #12
0
ファイル: ImageAdapter.cs プロジェクト: ashmind/gallery
        public void ReorientInPlace(ImageOrientation orientation)
        {
            if (orientation.Angle == 0 && orientation.Mirroring == ImageMirroring.None)
                return;

            this.Image.RotateFlip(rotateFlip[orientation]);
        }
コード例 #13
0
ファイル: PixbufUtils.cs プロジェクト: f-spot/f-spot-xplat
 public static ImageOrientation Rotate90(ImageOrientation orientation)
 {
     orientation = Rotate270(orientation);
     orientation = Rotate270(orientation);
     orientation = Rotate270(orientation);
     return(orientation);
 }
コード例 #14
0
        void OrientationSensor_ReadingChanged(object sender, OrientationSensorChangedEventArgs e)
        {
            Quaternion q = e.Reading.Orientation;

            const float eps   = 0.137472f;
            const float deg90 = 0.707f;

            if (q.X > 0 && Math.Abs(q.Y - q.Z) <= eps)
            {
                Orientation = ImageOrientation.Portrait;
            }
            else if (q.X < 0 && (Math.Abs(q.Y - q.Z) <= eps || Math.Abs(q.Y + q.Z) <= eps))
            {
                Orientation = ImageOrientation.PortraitBottom;
            }
            else if (Math.Abs(q.Z - q.X) <= eps && q.Y < 0)
            {
                Orientation = ImageOrientation.LandscapeLeft;
            }
            else if (Math.Abs(q.Z + q.X) <= eps && q.Y > 0)
            {
                Orientation = ImageOrientation.LandscapeRight;
            }
            else if (Math.Abs(q.X) <= eps && Math.Abs(q.Y) <= eps)
            {
                Orientation = ImageOrientation.Portrait;
            }
            else if (q.X < 0 && Math.Abs(q.Z) <= eps && Math.Abs(q.W) <= eps)
            {
                Orientation = ImageOrientation.Portrait;
            }

            SetOrientationToContext();
        }
コード例 #15
0
ファイル: ImageRotation.cs プロジェクト: lokeshshinde79/mugsy
        private void SetImageOrientation()
        {
            Image original = null;

            try
            {
                original = Image.FromStream(imageStream);

                float originalWidth  = (float)original.Width;
                float originalHeight = (float)original.Height;
                float aspectRatio    = originalWidth / originalHeight;

                if (aspectRatio > 1)
                {
                    this._ImageOrientation = ImageOrientation.Horizontal;
                }
                else if (aspectRatio == 1)
                {
                    this._ImageOrientation = ImageOrientation.Square;
                }
                else
                {
                    this._ImageOrientation = ImageOrientation.Vertical;
                }

                original.Dispose();
            }
            catch (Exception ex)
            {
                if (original != null)
                {
                    original.Dispose();
                }
            }
        }
コード例 #16
0
ファイル: ImageRotation.cs プロジェクト: lokeshshinde79/mugsy
        public void AutoRotate(string path, string filename, ImageOrientation orientation, byte imageFormat, long quality)
        {
            string ext = "";

            switch (imageFormat)
            {
            case 0:
                ext = "jpeg";
                break;

            case 1:
                ext = "png";
                break;

            default:
                ext = "jpeg";
                break;
            }

            //-- set output file name --//
            fileOutputName = filename + "." + ext;

            string fullpath = path + fileOutputName;
            Image  sampled  = RotateImageStream(orientation, imageFormat);

            //-- save thumbnail --//
            ImageCodecInfo    cinfo   = GetEncoderInfo(imageFormat);
            EncoderParameters eparams = GetEncoderParameters(quality);

            sampled.Save(fullpath, cinfo, eparams);
        }
コード例 #17
0
ファイル: PictureAd.cs プロジェクト: Katry4/Bloob-bloob
    public string getImageURL(ImageURLType imageURLType, ImageOrientation pictureOrientation, ImageType imageType) {
     	if(imageURLs == null || !imageURLs.ContainsKey(imageURLType)) return null;
				var imageURLTypeDict = imageURLs[imageURLType];
     	if(imageURLTypeDict == null || !imageURLTypeDict.ContainsKey(pictureOrientation)) return null;
				var pictureOrientationDict = imageURLTypeDict[pictureOrientation];
    	if(pictureOrientationDict == null || !pictureOrientationDict.ContainsKey(imageType)) return null;
      	return pictureOrientationDict[imageType];
    	}
コード例 #18
0
            public static IImage Image(ImageOrientation orientation = ImageOrientation.TopLeft)
            {
                var image = Substitute.For <IImage>();

                image.Orientation.Returns(orientation);

                return(image);
            }
コード例 #19
0
ファイル: PictureAd.cs プロジェクト: Katry4/Bloob-bloob
    public void setImageURL(string url, ImageURLType imageURLType, ImageOrientation pictureOrientation, ImageType imageType) { 
    	if(url == null || imageURLs == null || !imageURLs.ContainsKey(imageURLType)) return;
      	var imageURLTypeDict = imageURLs[imageURLType];
      if(imageURLTypeDict == null || !imageURLTypeDict.ContainsKey(pictureOrientation)) return;
      	var pictureOrientationDict = imageURLTypeDict[pictureOrientation];
			if(pictureOrientationDict == null) return;
				pictureOrientationDict[imageType] = url;
			System.Console.WriteLine(pictureOrientationDict[imageType]);
    }
コード例 #20
0
        private void OnImageLoad(string imagePath, Texture2D texture2D, ImageOrientation orientation)
        {
            ImageLoadedData loadedData = new ImageLoadedData();

            loadedData.imagePath    = imagePath;
            loadedData.imageTexture = texture2D;
            loadedData.orientation  = orientation;
            this.imageLoadEvent?.CallEvent(loadedData);
        }
コード例 #21
0
ファイル: SelfieHandler.cs プロジェクト: UMN-LATIS/SelfSnap
 void OnImageLoad(string path, Texture2D tex, ImageOrientation orientation)
 {
     //imageTexture.texture = tex;
     //byte[] bytes = tex.EncodeToPNG();
     //tempFile = Application.persistentDataPath + "SavedScreen.png";
     //File.WriteAllBytes(tempFile, bytes);
     //GameObject.Find("Cube").GetComponent<Renderer>().material.mainTexture = tex;
     //log += "\nImage Saved to gallery, loaded :" + path + ", orientation : " + orientation;
 }
コード例 #22
0
 void initTextureForOrientation(PictureAd ad, ImageOrientation imageOrientation)
 {
     blackTex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
     blackTex.SetPixel(0, 0, new Color(0.0f, 0.0f, 0.0f, 0.7f));
     blackTex.Apply();
     initTexture(imageOrientation, ImageType.Base, ad);
     initTexture(imageOrientation, ImageType.Frame, ad);
     initTexture(imageOrientation, ImageType.Close, ad);
 }
コード例 #23
0
ファイル: CardImage.cs プロジェクト: ecm85/Splendor
        public CardImage(string name, ImageOrientation orientation)
        {
            var bitmap = CreateBitmap(orientation);

            Bitmap      = bitmap;
            Orientation = orientation;
            Graphics    = Graphics.FromImage(bitmap);
            Name        = name;
        }
コード例 #24
0
ファイル: IImageFile.cs プロジェクト: cizma/f-spot
        public BaseImageFile(SafeUri uri)
        {
            Uri         = uri;
            Orientation = ImageOrientation.TopLeft;

            using (var metadata_file = Metadata.Parse(uri)) {
                ExtractMetadata(metadata_file);
            }
        }
コード例 #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inImgOrientation"></param>
        public LocationInfo(ImageOrientation inImgOrientation)
        {
            _locBckImage = new LocationBackImage(inImgOrientation);


            Width  = _locBckImage.BackImage.Width;
            Height = _locBckImage.BackImage.Height;

            _tableList = new List <TableInfo>();
        }
コード例 #26
0
        /// <summary>
        /// Gets the exif.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="format">The format.</param>
        /// <returns>System.Byte[][].</returns>
        public byte[] SetOrientation(byte[] bytes, ImageFormat format)
        {
            if (format.Equals(ImageFormat.Jpeg))
            {
                var orientation = new ImageOrientation(bytes);
                bytes = orientation.OrientImage();
            }

            return(bytes);
        }
コード例 #27
0
        public virtual RecognitionResult ProcessImageFile(string image_file, ImageOrientation image_orientation)
        {
            RecognitionResult ret = new RecognitionResult(csSmartIdEnginePINVOKE.RecognitionSession_ProcessImageFile__SWIG_2(swigCPtr, image_file, (int)image_orientation), true);

            if (csSmartIdEnginePINVOKE.SWIGPendingException.Pending)
            {
                throw csSmartIdEnginePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #28
0
        public virtual RecognitionResult ProcessImage(Image image, Rectangle roi, ImageOrientation image_orientation)
        {
            RecognitionResult ret = new RecognitionResult(csSmartIdEnginePINVOKE.RecognitionSession_ProcessImage__SWIG_0(swigCPtr, Image.getCPtr(image), Rectangle.getCPtr(roi), (int)image_orientation), true);

            if (csSmartIdEnginePINVOKE.SWIGPendingException.Pending)
            {
                throw csSmartIdEnginePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #29
0
        public ImageOrientation OrientationGetTest([PexAssumeUnderTest] XmpTag target, ImageOrientation value)
        {
            PexAssume.IsNotNull(value);
            PexAssume.IsTrue((uint)value >= 1U && (uint)value <= 8U);
            target.Orientation = value;
            ImageOrientation result = target.Orientation;

            PexAssert.AreEqual(result, (ImageOrientation)target.GetUIntNode(XmpTag.TIFF_NS, "Orientation"));
            return(result);
            // TODO: add assertions to method XmpTagTest.OrientationGetTest(XmpTag)
        }
コード例 #30
0
ファイル: ImageRotation.cs プロジェクト: lokeshshinde79/mugsy
        private Image RotateImageStream(ImageOrientation orientation, byte imageFormat)
        {
            RotateFlipType flipType = RotateFlipType.RotateNoneFlipNone;

            if (_ImageOrientation != orientation)
            {
                flipType = RotateFlipType.Rotate90FlipNone;
            }

            return(RotateImageStream(flipType, imageFormat));
        }
コード例 #31
0
ファイル: ImageCreator.cs プロジェクト: ecm85/AdinaCardGame
        private Bitmap CreateBitmap(ImageOrientation orientation)
        {
            switch (orientation)
            {
            case ImageOrientation.Landscape:
                return(CreateBitmap(CardHeightInPixelsWithBleed, CardWidthInPixelsWithBleed));

            case ImageOrientation.Portrait:
                return(CreateBitmap(CardWidthInPixelsWithBleed, CardHeightInPixelsWithBleed));
            }
            return(null);
        }
コード例 #32
0
        static void Main(string[] args)
        {
            Console.Write("Image width: ");
            int width = Convert.ToInt32(Console.ReadLine());

            Console.Write("Image height: ");
            int height = Convert.ToInt32(Console.ReadLine());

            ImageOrientation orientation = width > height ? ImageOrientation.Landscape : ImageOrientation.Portrait;

            Console.WriteLine("Image orientation is " + orientation);
        }
コード例 #33
0
ファイル: ImageInfo.cs プロジェクト: Squidex/assets
        public ImageInfo(int pixelWidth, int pixelHeight, ImageOrientation orientation, ImageFormat format)
        {
            Guard.GreaterThan(pixelWidth, 0, nameof(pixelWidth));
            Guard.GreaterThan(pixelHeight, 0, nameof(pixelHeight));

            Format = format;

            PixelWidth  = pixelWidth;
            PixelHeight = pixelHeight;

            Orientation = orientation;
        }
コード例 #34
0
        private Bitmap CreateBitmap(ImageOrientation orientation)
        {
            switch (orientation)
            {
            case ImageOrientation.Landscape:
                return(GraphicsUtilities.CreateBitmap(CardLongSideInPixelsWithBleed, CardShortSideInPixelsWithBleed));

            case ImageOrientation.Portrait:
                return(GraphicsUtilities.CreateBitmap(CardShortSideInPixelsWithBleed, CardLongSideInPixelsWithBleed));
            }
            return(null);
        }
コード例 #35
0
ファイル: PixbufUtils.cs プロジェクト: mono/f-spot
		public static Rectangle TransformOrientation (int total_width, int total_height, Rectangle args, ImageOrientation orientation)
		{
			Rectangle area = args;
			
			switch (orientation) {
			case ImageOrientation.BottomRight:
				area.X = total_width - args.X - args.Width;
				area.Y = total_height - args.Y - args.Height;
				break;
			case ImageOrientation.TopRight:
				area.X = total_width - args.X - args.Width;
				break;
			case ImageOrientation.BottomLeft:
				area.Y = total_height - args.Y - args.Height;
				break;
			case ImageOrientation.LeftTop:
				area.X = args.Y;
				area.Y = args.X;
				area.Width = args.Height;
				area.Height = args.Width;
				break;
			case ImageOrientation.RightBottom:
				area.X = total_height - args.Y - args.Height;
				area.Y = total_width - args.X - args.Width;
				area.Width = args.Height;
				area.Height = args.Width;
				break;
			case ImageOrientation.RightTop:
				area.X = total_height - args.Y - args.Height;
				area.Y = args.X;
				area.Width = args.Height;
				area.Height = args.Width;
				break;
			case ImageOrientation.LeftBottom:
				area.X = args.Y;
				area.Y = total_width - args.X - args.Width;
				area.Width = args.Height;
				area.Height = args.Width;
				break;
			default:
				break;
			}
			
			return area;
		}
コード例 #36
0
ファイル: PixbufUtils.cs プロジェクト: Yetangitu/f-spot
 public static ImageOrientation ReverseTransformation(ImageOrientation orientation)
 {
     switch (orientation) {
     default:
     case ImageOrientation.TopLeft:
     case ImageOrientation.TopRight:
     case ImageOrientation.BottomRight:
     case ImageOrientation.BottomLeft:
         return orientation;
     case ImageOrientation.LeftTop:
         return ImageOrientation.RightBottom;
     case ImageOrientation.RightTop:
         return ImageOrientation.LeftBottom;
     case ImageOrientation.RightBottom:
         return ImageOrientation.LeftTop;
     case ImageOrientation.LeftBottom:
         return ImageOrientation.RightTop;
     }
 }
コード例 #37
0
ファイル: PixbufUtils.cs プロジェクト: Yetangitu/f-spot
        public static ImageOrientation Rotate270(ImageOrientation orientation)
        {
            if (orientation == ImageOrientation.None) {
                    orientation = ImageOrientation.TopLeft;
                }

                ImageOrientation [] rot = new ImageOrientation [] {
                    ImageOrientation.LeftBottom,
                        ImageOrientation.LeftTop,
                        ImageOrientation.RightTop,
                        ImageOrientation.RightBottom,
                        ImageOrientation.BottomLeft,
                        ImageOrientation.TopLeft,
                        ImageOrientation.TopRight,
                        ImageOrientation.BottomRight
                };

                orientation = rot [((int)orientation) -1];
                return orientation;
        }
コード例 #38
0
    Rect rectWithPrecentage(int precentageSize, ImageOrientation imageOrientation) {
      bool isLandscape = (bool)(imageOrientation == ImageOrientation.Landscape);
      float heightProportion = Screen.width > Screen.height ? (float)9 / (float)16 : (float)16 / (float)9;
      float widthProportion = (float)1 / (float)heightProportion;
      int majorSizeValue = (Screen.width > Screen.height ? Screen.width : Screen.height) * precentageSize / 100;
      float finalTextureHeight = (float)majorSizeValue * (Screen.width > Screen.height ? (float)heightProportion : (float)widthProportion);
      finalTextureHeight = (finalTextureHeight > 
        ((Screen.width > Screen.height ? Screen.height : Screen.width) * precentageSize / 100) ?
        ((Screen.width > Screen.height ? Screen.height : Screen.width) * precentageSize / 100) : finalTextureHeight);
      Rect landscapeRect = new Rect(((Screen.width > Screen.height ? Screen.width : Screen.height) - majorSizeValue) / 2,
                                     ((Screen.width > Screen.height ? Screen.height : Screen.width) - finalTextureHeight) / 2,
                                     majorSizeValue,
                                     finalTextureHeight);

      Rect portraitRect = new Rect(((Screen.width > Screen.height ? Screen.height : Screen.width) - finalTextureHeight) / 2,
                                    ((Screen.width > Screen.height ? Screen.width : Screen.height) - majorSizeValue) / 2,
                                    finalTextureHeight,
                                    majorSizeValue);
      return (isLandscape ? landscapeRect : portraitRect);
    }
コード例 #39
0
		void executeRequestForResource(PictureAd ad, ImageOrientation imageOrientation, ImageType imageType) {
			string filePath = ad.getLocalImageURL(imageOrientation, imageType);
			if (System.IO.File.Exists(filePath)) {
				downloadedResourcesCount++;
				if(downloadedResourcesCount == PictureAd.expectedResourcesCount) {
					_resourcesAvailable ();
					_operationCompleteDelegate();
				}
				return;
			}
			string url = ad.getRemoteImageURL(imageOrientation, imageType);
			HTTPRequest pictureURLRequest = new HTTPRequest(url);
			pictureURLRequest.execute(pictureURLRequestResponse => {
				downloadedResourcesCount ++;
				if(pictureURLRequestResponse.dataLength != 0)
					System.IO.File.WriteAllBytes(ad.getLocalImageURL(imageOrientation, imageType), pictureURLRequestResponse.data);
				
				if(downloadedResourcesCount == PictureAd.expectedResourcesCount) {
					_resourcesAvailable ();
					_operationCompleteDelegate();
				}
			});
		}
コード例 #40
0
ファイル: PixbufUtils.cs プロジェクト: Yetangitu/f-spot
        public static Pixbuf TransformOrientation(Pixbuf src, ImageOrientation orientation)
        {
            Pixbuf dest;

            switch (orientation) {
            default:
            case ImageOrientation.TopLeft:
                dest = PixbufUtils.ShallowCopy (src);
                break;
            case ImageOrientation.TopRight:
                dest = src.Flip (false);
                break;
            case ImageOrientation.BottomRight:
                dest = src.RotateSimple (PixbufRotation.Upsidedown);
                break;
            case ImageOrientation.BottomLeft:
                dest = src.Flip (true);
                break;
            case ImageOrientation.LeftTop:
                using (var rotated = src.RotateSimple (PixbufRotation.Clockwise)) {
                    dest = rotated.Flip (false);
                }
                break;
            case ImageOrientation.RightTop:
                dest = src.RotateSimple (PixbufRotation.Clockwise);
                break;
            case ImageOrientation.RightBottom:
                using (var rotated = src.RotateSimple (PixbufRotation.Counterclockwise)) {
                    dest = rotated.Flip (false);
                }
                break;
            case ImageOrientation.LeftBottom:
                dest = src.RotateSimple (PixbufRotation.Counterclockwise);
                break;
            }

            return dest;
        }
コード例 #41
0
        /// <summary>
        /// Sets a margin of 10 between the image and the text.
        /// </summary>
        /// <param name="image">The image to add a margin to.</param>
        /// <param name="orientation">The orientation of the image on the button.</param>
        private static void SetImageMargin(System.Windows.Controls.Image image, ImageOrientation orientation)
        {
            const int defaultMargin = 10;
            int left = 0;
            int top = 0;
            int right = 0;
            int bottom = 0;

            switch (orientation)
            {
                case ImageOrientation.ImageToLeft:
                    right = defaultMargin;
                    break;
                case ImageOrientation.ImageOnTop:
                    bottom = defaultMargin;
                    break;
                case ImageOrientation.ImageToRight:
                    left = defaultMargin;
                    break;
                case ImageOrientation.ImageOnBottom:
                    top = defaultMargin;
                    break;
            }

            image.Margin = new System.Windows.Thickness(left, top, right, bottom);
        }
コード例 #42
0
ファイル: PixbufUtils.cs プロジェクト: Yetangitu/f-spot
 public static Rectangle TransformOrientation(Pixbuf src, Rectangle args, ImageOrientation orientation)
 {
     return TransformOrientation (src.Width, src.Height, args, orientation);
 }
コード例 #43
0
ファイル: PixbufUtils.cs プロジェクト: Yetangitu/f-spot
        public static Point TransformOrientation(int total_width, int total_height, Point args, ImageOrientation orientation)
        {
            Point p = args;

            switch (orientation) {
            default:
            case ImageOrientation.TopLeft:
                break;
            case ImageOrientation.TopRight:
                p.X = total_width - p.X;
                break;
            case ImageOrientation.BottomRight:
                p.X = total_width - p.X;
                p.Y = total_height - p.Y;
                break;
            case ImageOrientation.BottomLeft:
                p.Y = total_height - p.Y;
                break;
            case ImageOrientation.LeftTop:
                p.X = args.Y;
                p.Y = args.X;
                break;
            case ImageOrientation.RightTop:
                p.X = total_height - args.Y;
                p.Y = args.X;
                break;
            case ImageOrientation.RightBottom:
                p.X = total_height - args.Y;
                p.Y = total_width - args.X;
                break;
            case ImageOrientation.LeftBottom:
                p.X = args.Y;
                p.Y = total_width - args.X;
                break;
            }
            return p;
        }
コード例 #44
0
        /// <summary>
        /// Gets the exif.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="format">The format.</param>
        /// <returns>System.Byte[][].</returns>
        public byte[] SetOrientation(byte[] bytes, ImageFormat format)
        {
            if (format.Equals(ImageFormat.Jpeg))
            {
                var orientation = new ImageOrientation(bytes);
                bytes = orientation.OrientImage();
            }

            return bytes;
        }
コード例 #45
0
 void initRectsForOrientation(PictureAd ad, ImageOrientation imageOrientation) {
   Rect frameRect = rectWithPrecentage(ad.getImageSpace(ImageType.Frame), imageOrientation);
   Rect baseRect = rectWithPrecentage(ad.getImageSpace(ImageType.Base), imageOrientation);
   Rect closeButtonRect = rectWithPrecentage(ad.getImageSpace(ImageType.Close), imageOrientation);
   float maxV = Math.Max(closeButtonRect.width, closeButtonRect.height);
   closeButtonRect = new Rect((baseRect.x + baseRect.width) - closeButtonRect.width / 2, baseRect.y - closeButtonRect.height / 2, maxV, maxV);
   Rect closeActiveAreaRect = new Rect((float)(closeButtonRect.x - closeButtonRect.width * 0.3), 
                                        (float)(closeButtonRect.y - closeButtonRect.height * 0.3),
                                        (float)(closeButtonRect.width + closeButtonRect.width * 0.3),
                                        (float)(closeButtonRect.height + closeButtonRect.height * 0.3));
   initRect(imageOrientation, ImageType.Base, baseRect);
   initRect(imageOrientation, ImageType.Frame, frameRect);
   initRect(imageOrientation, ImageType.Close, closeButtonRect);
   initRect(imageOrientation, ImageType.CloseActiveArea, closeActiveAreaRect);
 }
コード例 #46
0
ファイル: PixbufUtils.cs プロジェクト: GNOME/f-spot
 public Pixbuf LoadFromFile(string path)
 {
     try {
         orientation = GetOrientation (new SafeUri (path));
         using (FileStream fs = System.IO.File.OpenRead (path)) {
             return Load (fs, orientation);
         }
     } catch (Exception) {
         Log.ErrorFormat ("Error loading photo {0}", path);
         return null;
     }
 }
コード例 #47
0
ファイル: PictureAd.cs プロジェクト: Katry4/Bloob-bloob
 public string getRemoteImageURL(ImageOrientation pictureOrientation, ImageType imageType) {
   return getImageURL(ImageURLType.Remote, pictureOrientation, imageType);
 }
コード例 #48
0
ファイル: ImageImpl.cs プロジェクト: SabotageAndi/efl-sharp
 protected static extern void elm_image_orient_set(IntPtr obj, ImageOrientation orientation);
コード例 #49
0
ファイル: PixbufUtils.cs プロジェクト: GNOME/f-spot
        public Pixbuf Load(System.IO.Stream stream, ImageOrientation orientation)
        {
            int count;
            byte [] data = new byte [8192];
            while (((count = stream.Read (data, 0, data.Length)) > 0) && loader.Write (data, (ulong)count)) {
                ;
            }

            loader.Close ();
            Pixbuf orig = loader.Pixbuf;
            Gdk.Pixbuf rotated = FSpot.Utils.PixbufUtils.TransformOrientation (orig, orientation);

            if (orig != rotated)
                orig.Dispose ();
            loader.Dispose ();
            return rotated;
        }
コード例 #50
0
 void initRect(ImageOrientation imageOrientation, ImageType imageType, Rect rect) {
   texturesRects[imageOrientation][imageType] = rect;
 }
コード例 #51
0
 ImageOrientation getScreenOrientation() {
   return screenOrientation = Screen.width > Screen.height ? ImageOrientation.Landscape : ImageOrientation.Portrait;
 }
コード例 #52
0
    void initTextureForOrientation(PictureAd ad, ImageOrientation imageOrientation) {
	  	blackTex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
	  	blackTex.SetPixel(0, 0, new Color(0.0f, 0.0f, 0.0f, 0.7f));
	  	blackTex.Apply();
      initTexture(imageOrientation, ImageType.Base, ad);
      initTexture(imageOrientation, ImageType.Frame, ad);
      initTexture(imageOrientation, ImageType.Close, ad);
    }
コード例 #53
0
 void executeRequestForResource(PictureAd ad, ImageOrientation imageOrientation, ImageType imageType)
 {
     string filePath = ad.getLocalImageURL(imageOrientation, imageType);
     if (System.IO.File.Exists(filePath)) {
         downloadedResourcesCount++;
         if(downloadedResourcesCount == PictureAd.expectedResourcesCount) {
             _resourcesAvailable ();
             _operationCompleteDelegate();
         }
         return;
     }
     string url = ad.getRemoteImageURL(imageOrientation, imageType);
     HTTPRequest pictureURLRequest = new HTTPRequest(url);
     imageTypes[url] = imageType;
     imageOrientations[url] = imageOrientation;
     HTTPManager.sendFileRequest(pictureURLRequest, HTTPFileCallback, retryDelays, 20 * 60);
 }
コード例 #54
0
        public void Load(SafeUri uri)
        {
            if (is_disposed)
                return;

            //First, send a thumbnail if we have one
            if ((thumb = XdgThumbnailSpec.LoadThumbnail (uri, ThumbnailSize.Large, null)) != null) {
                pixbuf_orientation = ImageOrientation.TopLeft;
                EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
                if (prep != null)
                    prep (this, new AreaPreparedEventArgs (true));
                EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
                if (upd != null)
                    upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
            }

            using (var image_file = ImageFile.Create (uri)) {
                image_stream = image_file.PixbufStream ();
                pixbuf_orientation = image_file.Orientation;
            }

            loading = true;
            // The ThreadPool.QueueUserWorkItem hack is there cause, as the bytes to read are present in the stream,
            // the Read is CompletedAsynchronously, blocking the mainloop
            image_stream.BeginRead (buffer, 0, count, delegate (IAsyncResult r) {
                ThreadPool.QueueUserWorkItem (delegate {HandleReadDone (r);});
            }, null);
        }
コード例 #55
0
ファイル: PictureAdsParser.cs プロジェクト: Keyj1n/BattlePong
		static void setupPathsForAd(PictureAd ad, string localCachePath, string remotePath, ImageOrientation orientation, ImageType imageType) {
			ad.setImageURL(remotePath, ImageURLType.Remote, orientation, imageType);
			ad.setImageURL(localPathForResource(localCachePath, remotePath), ImageURLType.Local, orientation, imageType);
		}
コード例 #56
0
        /// <summary>
        ///     Returns the alignment of the label on the button depending on the orientation.
        /// </summary>
        /// <param name="imageOrientation">The orientation to use.</param>
        /// <returns>The alignment to use for the text.</returns>
        private static TextAlignment GetTextAlignment(ImageOrientation imageOrientation)
        {
            TextAlignment returnValue;
            switch (imageOrientation)
            {
                case ImageOrientation.ImageToLeft:
                    returnValue = TextAlignment.Left;
                    break;
                case ImageOrientation.ImageToRight:
                    returnValue = TextAlignment.Right;
                    break;
                default:
                    returnValue = TextAlignment.Center;
                    break;
            }

            return returnValue;
        }
コード例 #57
0
ファイル: PictureAd.cs プロジェクト: Katry4/Bloob-bloob
 public string getLocalImageURL(ImageOrientation pictureOrientation, ImageType imageType) {
   return getImageURL(ImageURLType.Local, pictureOrientation, imageType);
 }
コード例 #58
0
        /// <summary>
        ///     Sets a margin of 10 between the image and the text.
        /// </summary>
        /// <param name="image">The image to add a margin to.</param>
        /// <param name="orientation">The orientation of the image on the button.</param>
        private static void SetImageMargin(Image image, ImageOrientation orientation)
        {
            const int DefaultMargin = 10;
            var left = 0;
            var top = 0;
            var right = 0;
            var bottom = 0;

            switch (orientation)
            {
                case ImageOrientation.ImageToLeft:
                    right = DefaultMargin;
                    break;
                case ImageOrientation.ImageOnTop:
                    bottom = DefaultMargin;
                    break;
                case ImageOrientation.ImageToRight:
                    left = DefaultMargin;
                    break;
                case ImageOrientation.ImageOnBottom:
                    top = DefaultMargin;
                    break;
            }

            image.Margin = new Thickness(left, top, right, bottom);
        }
コード例 #59
0
ファイル: Accelerometer.cs プロジェクト: GNOME/f-spot
        public static ImageOrientation GetViewOrientation(ImageOrientation po)
        {
            if (timer == 0 && available)
                SetupAccelerometer ();

            if (CurrentOrientation == Orient.TiltCounterclockwise)
                return FSpot.Utils.PixbufUtils.Rotate90 (po);

            if (CurrentOrientation == Orient.TiltClockwise)
                return FSpot.Utils.PixbufUtils.Rotate270 (po);

            return po;
        }
コード例 #60
0
 void initTexture(ImageOrientation imageOrientation, ImageType imageType, PictureAd ad) {
   textures[imageOrientation][imageType] = textureFromBytes(textureBytesForFrame(ad.getLocalImageURL(imageOrientation, imageType)));
 }