无法访问类型为Camera的封闭实例

时间:2013-04-18 08:25:39

标签: java android camera

大家好我正在开发一个我需要使用相机的应用程序,我的代码遇到了这个问题:

  

无法访问类型为Camera的封闭实例。必须使用类型为Camera的封闭实例限定分配(例如x.new A(),其中x是Camera的实例),行“this.preSize_ = new Camera(0,0);   有帮助吗?或建议?

private void setupCamera()
  {
    this.camera_ = Camera.open();
    Camera localCamera = this.camera_;
    localCamera.getClass();
    this.preSize_ =  new Camera.Size(0,0);
    Camera.Parameters localParameters = this.camera_.getParameters();
    Iterator<Camera.Size> localIterator1 = localParameters.getSupportedPreviewSizes().iterator();
    Camera.Size localSize2;
    do
    {
      if (!localIterator1.hasNext())
        break;
      localSize2 = (Camera.Size)localIterator1.next();
      this.preSize_ = localSize2;
    }
    while ((localSize2.width != this.previewWidth) && (localSize2.height != this.previewHeight));
    localParameters.setPreviewSize(this.preSize_.width, this.preSize_.height);
    Iterator<Camera.Size> localIterator2 = localParameters.getSupportedPictureSizes().iterator();
    Camera.Size localSize1;
    do
    {
      if (!localIterator2.hasNext())
        break;
      localSize1 = (Camera.Size)localIterator2.next();
      this.procSize_ = localSize1;
    }
    while ((localSize1.width != this.processWidth) && (localSize1.height != this.processHeight));
    localParameters.setPictureSize(this.procSize_.width, this.procSize_.height);
    this.camera_.setParameters(localParameters);
    this.camera_.setDisplayOrientation(90);
    try
    {
      this.camera_.setPreviewDisplay(this.surfaceHolder_);
      this.camera_.startPreview();
      return;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }

1 个答案:

答案 0 :(得分:3)

Size类是Camera的非静态类。因此,您只能从封闭的Camera类实例创建它。像这样:

this.preSize_ = localCamera.new Size(0,0);