D / skia:png错误IDAT:CRC错误编解码器-> getAndroidPixels()失败

时间:2018-12-24 05:31:12

标签: android video stream png skia

我正在尝试制作简单的视频流应用。图像在服务器上捕获并保存为png,然后将其转换为字节,并通过Internet(或本地网络)发送到android应用,该应用将字节另存为png并显示在显示屏上。我不断收到错误消息

D/skia: ------ png error IDAT: CRC error
D/skia: --- codec->getAndroidPixels() failed.

我似乎找不到任何可以提供该错误信息的地方。有任何想法吗?非常感谢您的帮助。

public class MainActivity extends AppCompatActivity {

public static volatile ImageView mainView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
}

public void startStream(View v){
    mainView = findViewById(R.id.imageView);
    Thread stream = new Thread(new streamThread(this));
    stream.start();
}
}

class streamThread implements Runnable{
Activity act;

public streamThread(Activity activity){
    act = activity;
}
@Override
public void run() {
    try {
        Socket sock = new Socket("10.1.10.107", 6879);

        InputStream sockIn = sock.getInputStream();

        TimeUnit.SECONDS.sleep(1);
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(act.getFilesDir() +  "/tempImg.png"));


        while(true){
            byte[] rData = new byte[2332800];

            sockIn.read(rData);

            bos.write(rData);

            act.runOnUiThread(new Runnable() //run on ui thread
            {
                public void run()
                {

                    MainActivity.mainView.setImageBitmap(BitmapFactory.decodeFile(act.getFilesDir() + "/tempImg.png"));

                }
            });

        }
    }catch(Exception e){
        Log.e("exception", e.getMessage());
    }
}
}

0 个答案:

没有答案