IEnumerator LoadImage(WWW www) { yield return(www); Debug.Log("tLoad"); // tDynamicTx= new Texture2D((int)UsetPhotoSize.x, (int)UsetPhotoSize.y); tDynamicTx = new Texture2D(175, 175); Debug.Log("tDynamicTx"); tLoad.LoadImageIntoTexture(tDynamicTx); tLoad.Dispose(); tDynamicTx = UtilMgr.ScaleTexture(tDynamicTx, (int)175, (int)175); //transform.FindChild("Photo").GetComponent<UITexture> ().mainTexture = tDynamicTx; //Save (tDynamicTx); Debug.Log("Image name : " + images); Setimage = tDynamicTx; byte[] bytes = tDynamicTx.EncodeToPNG(); if (CheckInGallery) { GalleryCheck = true; CheckInGallery = false; } SetMemberPhoto(bytes); // SetMemberPhoto(tDynamicTx); }
void Update() { // ShowStatus (); if (GetState() == STATE.Complete) { UITexture imgPreview = UtilMgr.GetChildObj(gameObject, "ImgPreview").GetComponent <UITexture>(); SetTexture(UtilMgr.ScaleTexture(mTexture, ThumbsWidth, ThumbsHeight)); imgPreview.mainTexture = GetTexture(); mTexture = null; SetState(STATE.Shown); } // else if(GetStatus() == Status.Switching) // { // UITexture imgPreview = UtilMgr.GetChildObj (gameObject, "ImgPreview").GetComponent<UITexture>(); // imgPreview.mainTexture = GetTexture(); // mStatus = Status.Shown; // } // if(GetListItem().GetStatus() != UIListItem.Status.None) // { // ResetItem(); // GetListItem().SetStatus(UIListItem.Status.None); // } }
IEnumerator LoadImage2(WWW tLoad) { yield return(tLoad); Debug.Log("tLoad"); // tDynamicTx= new Texture2D((int)UsetPhotoSize.x, (int)UsetPhotoSize.y); Texture2D tDynamicTx = new Texture2D(0, 0); Debug.Log("tDynamicTx"); tLoad.LoadImageIntoTexture(tDynamicTx); tLoad.Dispose(); tDynamicTx = UtilMgr.ScaleTexture(tDynamicTx, 206, 230); //transform.FindChild("Photo").GetComponent<UITexture> ().mainTexture = tDynamicTx; //Save (tDynamicTx); transform.FindChild("PanelPhoto").FindChild("TexPhoto").GetComponent <UITexture>().mainTexture = tDynamicTx; ImageBate = tDynamicTx.EncodeToPNG(); }
IEnumerator LoadImage(WWW www) { yield return(www); Texture2D tempTex = new Texture2D(0, 0); www.LoadImageIntoTexture(tempTex); www.Dispose(); int width = tempTex.width; int height = tempTex.height; float targetWidth = 0; float targetHeight = 0; if (width > height) { float ratio = 200f / width; targetWidth = width * ratio; targetHeight = height * ratio; } else { float ratio = 200f / height; targetWidth = width * ratio; targetHeight = height * ratio; } Debug.Log("width : " + targetWidth + ", height : " + targetHeight); tempTex = UtilMgr.ScaleTexture(tempTex, (int)targetWidth, (int)targetHeight); byte[] bytes = tempTex.EncodeToPNG(); mTempFile = UtilMgr.GetDateTimeNow("yyyyMMddHHmmss.png"); mTempFile = Application.temporaryCachePath + "/" + mTempFile; try{ System.IO.File.WriteAllBytes(mTempFile, bytes); } catch { mTempFile = ""; } UploadFile(); }