Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Problem with load image from www

Discussion in '2D' started by Ahboo, Jan 11, 2015.

  1. Ahboo

    Ahboo

    Joined:
    Dec 13, 2014
    Posts:
    3
    Hello everyone~

    I have problem with load image from www

    After loading,
    Some image looks fine:

    Some image looks bad:


    and here is my project:
    LoadImage.rar

    and script:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4.  
    5. public class LoadImage : MonoBehaviour {
    6.     public Image _image;
    7.  
    8.     void Start () {
    9.         _image.preserveAspect = true;
    10.         // This Image is Fine
    11.         //StartCoroutine(Load("http://img7.8comic.com/3/9337/2/001_avx.jpg"));
    12.         StartCoroutine(Load("http://img7.8comic.com/3/9337/3/001_3fm.jpg"));
    13.  
    14.         // This Image has problem
    15.         //StartCoroutine(Load("http://img7.8comic.com/3/9337/5/001_rc6.jpg"));
    16.         //StartCoroutine(Load("http://img7.8comic.com/3/9337/5/002_d75.jpg"));
    17.     }
    18.  
    19.     IEnumerator Load(string url) {
    20.         Debug.Log ("Start Loading Image...");
    21.         WWW www = new WWW(url);
    22.         yield return www;
    23.         if (www.error == null) {
    24.             _image.overrideSprite = (Sprite) Sprite.Create(www.texture,
    25.                                                            new Rect(0, 0, www.texture.width, www.texture.height),
    26.                                                            Vector2.zero);
    27.             Debug.Log ("Image Loaded.");
    28.         } else {
    29.             Debug.Log (www.error);
    30.         }
    31.     }
    32. }
    33.  
    I think maybe this's WWW's problem,
    cause image looks fine if I load image from project.

    Anyone know how to fix it :(?
     
    Last edited: Jan 11, 2015
  2. BlaXun

    BlaXun

    Joined:
    Jan 8, 2015
    Posts:
    52
    Your images are broken
     
  3. Ahboo

    Ahboo

    Joined:
    Dec 13, 2014
    Posts:
    3
  4. BlaXun

    BlaXun

    Joined:
    Jan 8, 2015
    Posts:
    52
    I meant those you tried to post. I can see em...broken links...the screenshots...those two on the top of your post.
     
  5. Ahboo

    Ahboo

    Joined:
    Dec 13, 2014
    Posts:
    3
    I'm sorry :( , already update!
     
    Last edited: Jan 11, 2015
  6. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    387
    I had a problem with loading jpegs with WWW. It turned out they were 32bit jpeg. The standard only allows 16bit. They load fine in modern browsers ( they do not work in IE ) and unity editor but not WWW. They do not seem very common, most software will not make 32bit jpeg images.