protected internal override void onActivityResult(int requestCode, int resultCode, Intent data) { base.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (data == null) { return; } if (requestCode == REQUEST_CODE_SELECT_IMAGE_BACKGROUND) { Uri imageFileUri = data.Data; string strBackgroundImagePath = AnimationUtils.getRealPathFromURI(this, imageFileUri); // Check Valid Image File if (!AnimationUtils.isValidImagePath(strBackgroundImagePath)) { Toast.makeText(this, "Invalid image path or web image", Toast.LENGTH_LONG).show(); return; } // Set background image on the image view bmBackgroundBitmap = AnimationUtils.getSafeResizingBitmap(strBackgroundImagePath, mBackgroudnImageView.Width / 2, mBackgroudnImageView.Height / 2); if (bmBackgroundBitmap != null) { // mBackgroudnImageView.setImageBitmap(bmBackgroundBitmap); bmFilteredBitmap = bmBackgroundBitmap.copy(Bitmap.Config.ARGB_8888, true); if (mImageOperation != SifImageFilter.FILTER_ORIGINAL) { bmFilteredBitmap = SifImageFilter.filterImageCopy(bmBackgroundBitmap, mImageOperation, mImageOperationLevel); if (bmFilteredBitmap != null) { mBackgroudnImageView.ImageBitmap = bmFilteredBitmap; } else { Toast.makeText(mContext, "Fail to apply image filter", Toast.LENGTH_LONG).show(); } } if (bmFilteredBitmap != null) { bmFilteredBitmap = bmFilteredBitmap.copy(Bitmap.Config.ARGB_8888, false); SifImageFilter.setImageTransparency(bmFilteredBitmap, mTransparency); mBackgroudnImageView.ImageBitmap = bmFilteredBitmap; } // reset the transparency mTransparency = 0; } else { Toast.makeText(mContext, "Fail to set Background Image Path.", Toast.LENGTH_LONG).show(); } } } }
public override void onItemClick(AdapterView parent, View view, int position, long id) { if (outerInstance.bmBackgroundBitmap == null) { Toast.makeText(outerInstance.mContext, "Input image does not selected!, select Image firtsly", Toast.LENGTH_SHORT).show(); return; } outerInstance.mImageOperationIndex = position; outerInstance.mImageOperation = outerInstance.imageOperationByIndex[outerInstance.mImageOperationIndex]; if (outerInstance.mImageOperation == SifImageFilter.FILTER_ORIGINAL) { outerInstance.mBackgroudnImageView.ImageBitmap = outerInstance.bmBackgroundBitmap; } else { outerInstance.bmFilteredBitmap = outerInstance.bmBackgroundBitmap.copy(Bitmap.Config.ARGB_8888, true); if (outerInstance.mImageOperation != SifImageFilter.FILTER_ORIGINAL) { outerInstance.bmFilteredBitmap = SifImageFilter.filterImageCopy(outerInstance.bmBackgroundBitmap, outerInstance.mImageOperation, outerInstance.mImageOperationLevel); if (outerInstance.bmFilteredBitmap != null) { outerInstance.mBackgroudnImageView.ImageBitmap = outerInstance.bmFilteredBitmap; } else { Toast.makeText(outerInstance.mContext, "Fail to apply image filter", Toast.LENGTH_LONG).show(); } } if (outerInstance.bmFilteredBitmap != null) { outerInstance.bmFilteredBitmap = outerInstance.bmFilteredBitmap.copy(Bitmap.Config.ARGB_8888, false); SifImageFilter.setImageTransparency(outerInstance.bmFilteredBitmap, outerInstance.mTransparency); outerInstance.mBackgroudnImageView.ImageBitmap = outerInstance.bmFilteredBitmap; } // reset the transparency outerInstance.mTransparency = 0; } }