Android开发:用getDrawingCache方法获取ImageView中的图(6)

                                       m_fileOutPutStream.flush();

                                       m_fileOutPutStream.close();

                             }

                             catch (IOException e)

                             {

                                       e.printStackTrace();

                             }

           

                             if(!compare2Image(obmp, sbmp))

                             {

                                   Toast.makeText(this, "new picture", Toast.LENGTH_LONG).show();

                             }

                             else

                             {

                                   Toast.makeText(this, "old picture", Toast.LENGTH_LONG).show();

                             }

                  }

                  break;

           }

           return false;

      }


      @Override

      protected void onActivityResult(int requestCode, int resultCode, Intent data)

      {

               if((requestCode == 1) &&(resultCode ==RESULT_FIRST_USER + 2))

              {

                  Bitmap ret_bitmap =data.getParcelableExtra("ret_bitmap");

                  iv_photo.setScaleType(ScaleType.FIT_XY);

                  iv_photo.setImageBitmap(ret_bitmap);

              }

           super.onActivityResult(requestCode,resultCode, data);

      }

 

      // 简单的比较两个图像是否一致

    private boolean compare2Image(Bitmap bmp1,Bitmap bmp2)

    {

          int iteration = 0;

          int width = bmp1.getWidth();

          int height = bmp1.getHeight();

          if(width != bmp2.getWidth()) return false;

          if(height != bmp2.getHeight()) return false;

   

          if(width < height)

          {

                iteration = width;

          }

          else

          {

                iteration = height;

          }

           

          for(int i = 0; i < iteration; ++i)

         {              

                if(bmp1.getPixel(i, i) != bmp2.getPixel(i,i)) return false;

          }

          return true;

      }

}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwzfsz.html