ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

Android¿ª·¢£ºÓÃgetDrawingCache·½·¨»ñÈ¡ImageViewÖеÄͼÏñÐèҪעÒâµÄÎÊÌâ(Èý)
2014-11-24 11:36:41 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºAndroid ¿ª·¢ getDrawingCache ·½·¨ »ñÈ¡ ImageView ͼÏñ ÐèÒª ×¢Òâ ÎÊÌâ



// ½«µÃµ½sbmpдÈëÎļþ


FileOutputStream m_fileOutPutStream = null;


String filepath = Environment.getExternalStorageDirectory() +File.separator + "tempPhoto1.png";


try


{


m_fileOutPutStream= new FileOutputStream(filepath);


}


catch (FileNotFoundException e)


{


e.printStackTrace();


}



sbmp.compress(CompressFormat.PNG, 100, m_fileOutPutStream);



try


{


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;


}


}


Ê×Ò³ ÉÏÒ»Ò³ 1 2 3 ÏÂÒ»Ò³ βҳ 3/3/3
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºJavaµÄ·´É䣨reflect£©»úÖÆµÄѧϰ ÏÂһƪ£ºAndroid¿ª·¢£º³ÌÐòÖж¯Ì¬É趨×é¼þ..

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Spring Boot Java£º (2025-12-26 16:20:19)
¡¤Spring Boot¤ÇHello (2025-12-26 16:20:15)
¡¤Spring ¤Î»ù±¾¤«¤éŒ (2025-12-26 16:20:12)
¡¤C++Ä£°å (template) (2025-12-26 15:49:49)
¡¤C ÓïÑÔÖÐÄ£°åµÄ¼¸ÖÖ (2025-12-26 15:49:47)