萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 安卓開發 >> android 相機報錯 setParameters failed

android 相機報錯 setParameters failed

   List sizeList = parameters.getSupportedPreviewSizes();

  int PreviewWidth = 640;

  int PreviewHeight = 480;

  Boolean findSize = false;

  if (sizeList.size() > 1) {

  Iterator itor = sizeList.iterator();

  while (itor.hasNext()) {

  Camera.Size cur = itor.next();

  if (cur.width >= PreviewWidth

  && cur.height >= PreviewHeight) {

  findSize = true;

  PreviewWidth = cur.width;

  PreviewHeight = cur.height;

  break;

  }

  }

  }

  if (!findSize) {

  PreviewWidth = sizeList.get(0).width;

  PreviewHeight = sizeList.get(0).height;

  }

  parameters.setPreviewSize(PreviewWidth, PreviewHeight);

copyright © 萬盛學電腦網 all rights reserved