void testLocalPhoto2() { object textureObj = Resources.Load("test2", typeof(Texture2D)); Texture2D texture = (Texture2D)textureObj; //texture.anisoLevel = 1; //texture.filterMode = FilterMode.Bilinear; //texture.wrapMode = TextureWrapMode.Clamp; //scale to small size int aScaleSize = MediaBase.getAScaleSize(texture.width); TextureScale.Bilinear(texture, texture.width / aScaleSize, texture.height / aScaleSize); JpegInfo jpi = ExifReader.ReadJpeg(texture.EncodeToJPG(), "Foo"); int angle = 0; switch (jpi.Orientation) { case ExifOrientation.TopLeft: break; case ExifOrientation.TopRight: angle = -90; break; case ExifOrientation.BottomLeft: angle = 90; break; case ExifOrientation.BottomRight: angle = 180; break; } texture = TextureRotate.RotateImage(texture, angle); Sprite picture = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 1); PictureLoaded(true, "", picture); }
IEnumerator LoadPictureCoroutine(string path) { WWW www = new WWW(path); if (www.size == 0) { showlog("size 0"); yield return(new WaitForSeconds(1.0f)); LoadPicture(path); } else if (!string.IsNullOrEmpty(www.error)) { showlog("error"); PictureLoaded(false, null, null); } else { //ExifLib.JpegInfo jpi = ExifLib.ExifReader.ReadJpeg(www.bytes, "test2.jpg"); //showlog("EXIF: " + jpi.Orientation); //Texture2D texture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.RGB24, false); //texture.anisoLevel = 1; //texture.filterMode = FilterMode.Bilinear; //texture.wrapMode = TextureWrapMode.Clamp; //www.LoadImageIntoTexture(texture); //TextureScale.Bilinear(texture, texture.width / 5, texture.height / 5); //texture = TextureRotate.RotateImage(texture, -90); Texture2D texture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.RGB24, false); texture.anisoLevel = 1; texture.filterMode = FilterMode.Bilinear; texture.wrapMode = TextureWrapMode.Clamp; www.LoadImageIntoTexture(texture); //scale to small size int aScaleSize = MediaBase.getAScaleSize(texture.width); TextureScale.Bilinear(texture, texture.width / aScaleSize, texture.height / aScaleSize); JpegInfo jpi = ExifReader.ReadJpeg(www.bytes, "Foo"); int angle = 0; switch (jpi.Orientation) { case ExifOrientation.TopLeft: break; case ExifOrientation.TopRight: angle = -90; break; case ExifOrientation.BottomLeft: angle = 90; break; case ExifOrientation.BottomRight: angle = 180; break; } texture = TextureRotate.RotateImage(texture, angle); Sprite picture = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 1); PictureLoaded(true, path, picture); } }