@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1 && resultCode == RESULT_OK && data != null) { Uri selectedImage = data.getData(); String[] filePath = {MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query(selectedImage, filePath, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePath[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); ImageView image = (ImageView) findViewById(R.id.imageView2); image.setImageBitmap(BitmapFactory.decodeFile(picturePath)); imagepath = picturePath; } else if (requestCode == 2 && resultCode == RESULT_OK) { Bitmap photo = (Bitmap) data.getExtras().get("data"); ImageView image = (ImageView) findViewById(R.id.imageView2); image.setImageBitmap(photo); try { File imagefile = createImageFile(photo); Log.d("dir", imagefile.getAbsolutePath()); imagepath = imagefile.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); } } }
public void setContents(int index, String data) { if (index == 0) { itemDate.setText(data); } else if (index == 1) { itemText.setText(data); } else if (index == 2) { if (data == null || data.equals("-1") || data.equals("")) { itemHandwriting.setImageBitmap(null); } else { itemHandwriting.setImageURI(Uri.parse(BasicInfo.FOLDER_PHOTO + data)); } } else if (index == 3) { if (data == null || data.equals("-1") || data.equals("")) { itemPhoto.setImageResource(R.drawable.person); } else { if (bitmap != null) { bitmap.recycle(); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 8; bitmap = BitmapFactory.decodeFile(BasicInfo.FOLDER_PHOTO + data, options); itemPhoto.setImageBitmap(bitmap); } } else { throw new IllegalArgumentException(); } }
public void setAudio(Uri audio, String name, Map<String, ?> extras) { synchronized (this) { mAudioUri = audio; } mNameView.setText(name); mAlbumView.setText((String) extras.get("album")); mArtistView.setText((String) extras.get("artist")); String extName = name.substring(name.lastIndexOf('.') + 1); Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher_record_audio); if (extName.equals("dcf")) { MmsLog.i(TAG, "contain drm audio"); if (EncapsulatedFeatureOption.MTK_DRM_APP) { Drawable front = getResources().getDrawable(EncapsulatedR.drawable.drm_red_lock); EncapsulatedDrmManagerClient drmManager = new EncapsulatedDrmManagerClient(mContext); Bitmap drmBitmap = drmManager.overlayBitmap(bitmap, front); mAudioImageView.setImageBitmap(drmBitmap); if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); bitmap = null; } } else { mAudioImageView.setImageBitmap(bitmap); } } else { mAudioImageView.setImageBitmap(bitmap); } }
// the following method is based on the camera control activity from the lecture notes private void loadSnap(Uri uri) { try { // if there is a uri passed in, a new pro pic has been taken but the profile hasn't // been saved yet and the phone has been turned sideways, so load that new pic if (uri != null) { String urisplit = uri.toString(); String[] split_dash = urisplit.split("/"); String[] split = split_dash[6].split("\\."); String combine = split[0] + "~2." + split[1]; String path = "//" + Environment.getExternalStorageDirectory().toString() + "/"; String path_name = path + combine; Bitmap bmap = BitmapFactory.decodeFile(path_name); mProPic.setImageBitmap(bmap); } else { FileInputStream fis = openFileInput(getString(R.string.profile_photo_file_name)); Bitmap bmap = BitmapFactory.decodeStream(fis); mProPic.setImageBitmap(bmap); fis.close(); } } catch (IOException e) { // Default profile photo if no photo saved before. mProPic.setImageResource(R.drawable.default_profile); Log.d(TAG, e.getMessage()); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_CAMERA) { Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes); imageBytes = bytes.toByteArray(); File destination = new File( Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg"); FileOutputStream fo; try { destination.createNewFile(); fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (IOException e) { e.printStackTrace(); } image.setImageBitmap(thumbnail); } else if (requestCode == SELECT_FILE) { Bitmap bitmap = data.getExtras().getParcelable("data"); image.setImageBitmap(bitmap); ByteArrayOutputStream stream = new ByteArrayOutputStream(); // Compress image to lower quality scale 1 - 100 bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); imageBytes = stream.toByteArray(); } uploadButton.setEnabled(true); } }
protected void onCreateIcons() { ImageView icon_small = (ImageView) getOptionView().findViewById(R.id.icon_small); ImageView icon_big = (ImageView) getOptionView().findViewById(R.id.icon_big); Resources res = getContext().getBaseContext().getResources(); if (null != res) { int id = res.getIdentifier( "feather_tool_icon_" + mResourceName, "drawable", getContext().getBaseContext().getPackageName()); if (id > 0) { Bitmap big, small; try { Bitmap bmp = BitmapFactory.decodeResource(res, id); big = ThumbnailUtils.extractThumbnail( bmp, (int) (bmp.getWidth() / 1.5), (int) (bmp.getHeight() / 1.5)); bmp.recycle(); small = ThumbnailUtils.extractThumbnail( big, (int) (big.getWidth() / 1.5), (int) (big.getHeight() / 1.5)); } catch (OutOfMemoryError e) { e.printStackTrace(); return; } icon_big.setImageBitmap(big); icon_small.setImageBitmap(small); } } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { this.getActivity(); if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { // À´×ÔͼƬ¿â if (resultCode == FragmentActivity.RESULT_OK) { uri = data.getData(); if (uri != null) { ContentResolver cr = this.getActivity().getContentResolver(); try { Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri)); // ½«BitmapÉ趨µ½ImageView ivImage.setImageBitmap(bitmap); } catch (FileNotFoundException e) { Log.e("Exception", e.getMessage(), e); } } } } else if (requestCode == CAPTURE_CAMERA_ACTIVITY_REQUEST_CODE) { // À´×ÔÕÕÏà»ú if (resultCode == FragmentActivity.RESULT_OK) { if (data != null) { uri = data.getData(); if (data.hasExtra("data")) { Bitmap bitmap = data.getParcelableExtra("data"); // ½«BitmapÉ趨µ½ImageView ivImage.setImageBitmap(bitmap); } } } } super.onActivityResult(requestCode, resultCode, data); }
public void updateUI() { User u = MainActivity.getUser(); if (userName == null || u == null) { return; } points.setText("Points: " + u.getPoints()); level.setText("" + LevelPicker.levelPicker((int) u.getPoints())); userName.setText(MainActivity.getMeRequest().getMe().getFirstName()); byte[] profilePictureArray = u.getInAppProfilePicture(); if (profilePictureArray != null) { profilePicture.setImageBitmap( BitmapFactory.decodeByteArray(profilePictureArray, 0, profilePictureArray.length)); } else { profilePicture.setImageDrawable(getResources().getDrawable(R.drawable.ic_mood_24dp)); } if (MainActivity.getUserContentPreview() != null) { contentPicture.setImageBitmap(MainActivity.getUserContentPreview()); } else { contentPicture.setImageDrawable(getResources().getDrawable(R.drawable.ic_assignment_24dp)); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater theInflater = LayoutInflater.from(getContext()); View theView = theInflater.inflate(R.layout.single_row, parent, false); String results = getItem(position); TextView theTextView = (TextView) theView.findViewById(R.id.textView8); theTextView.setText(results); TextView descText = (TextView) theView.findViewById(R.id.textView9); descText.setText("Click to view Recipe!"); String yes = recipes.get(position).getImageUrl(); ImageView img = (ImageView) theView.findViewById(R.id.imageView); if (!cachedImages.containsKey(yes)) { Bitmap bitmap = getBitmapFromURL(yes); cachedImages.put(yes, bitmap); img.setImageBitmap(bitmap); } else { img.setImageBitmap(cachedImages.get(yes)); } return theView; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == 1) { Bitmap imagemFoto = BitmapFactory.decodeFile(path); Bitmap imagemFotoReduzida = Bitmap.createScaledBitmap(imagemFoto, imagemFoto.getWidth(), 300, true); viewImage.setImageBitmap(imagemFotoReduzida); viewImage.setTag(path); viewImage.setScaleType(ImageView.ScaleType.FIT_XY); } else if (requestCode == 2) { Uri selectedImage = data.getData(); String[] filePath = {MediaStore.Images.Media.DATA}; Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null); c.moveToFirst(); int columnIndex = c.getColumnIndex(filePath[0]); path = c.getString(columnIndex); c.close(); Bitmap thumbnail = (BitmapFactory.decodeFile(path)); viewImage.setImageBitmap(thumbnail); } } }
public void mueveSlider(String lado) { if (lado == "derecha") { bannerActual++; if (bannerActual < ((MenuActivity) context).getSizeBanners()) { if (((MenuActivity) context).getBanner(bannerActual) == null) { mueveSlider("derecha"); } else { bannerSlider.setImageBitmap(((MenuActivity) context).getBanner(bannerActual)); } } else { bannerSlider.setImageBitmap(((MenuActivity) context).getBanner(0)); bannerActual = 0; } } else { bannerActual--; if (bannerActual < 0) { bannerActual = ((MenuActivity) context).getSizeBanners() - 1; bannerSlider.setImageBitmap(((MenuActivity) context).getBanner(bannerActual)); } else { bannerSlider.setImageBitmap(((MenuActivity) context).getBanner(bannerActual)); } } iniciaSlider(); }
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { if (resultCode != RESULT_OK) return; if (requestCode == PICK_FROM_FILE) { mImageCaptureUri = imageReturnedIntent.getData(); path = getRealPathFromURI(mImageCaptureUri); // from Gallery if (path == null) path = mImageCaptureUri.getPath(); // from File Manager else { try { bitmap = decodeFile(new File(path)); } catch (Exception e) { path = null; bitmap = null; } } if (path != null) { photoBiere.setImageBitmap(bitmap); path = null; mImageCaptureUri = null; } } else { Bundle extras = imageReturnedIntent.getExtras(); bitmap = (Bitmap) extras.get("data"); photoBiere.setImageBitmap(bitmap); } }
private void update() { // TODO reload all fields based on new info from model // Loads title if (fragmentTitleTextView != null) fragmentTitleTextView.setText(fragment.getTitle()); // Loads fragment parts (text, images, videos, sounds, etc) adapter = new FragmentPartAdapter(this, R.layout.activity_fragment_editor, fragment); fragmentPartListView.setAdapter(adapter); Log.d(TAG, "UPDATE"); Log.d(TAG, fragment.getAnnotations().toString()); Log.d(TAG, "size" + fragment.getAnnotations().size()); File file; for (int i = 0; i < fragment.getAnnotations().size(); i++) { file = new File(fragment.getAnnotations().get(i)); Log.d(TAG, "" + file.getAbsoluteFile()); if (file.exists()) { Log.d(TAG, "existis"); if (i == 0) viewImage.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath())); if (i == 1) viewImage2.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath())); if (i == 2) viewImage3.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath())); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_developer); toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); img1 = (ImageView) findViewById(R.id.view); img2 = (ImageView) findViewById(R.id.view2); img3 = (ImageView) findViewById(R.id.view3); img4 = (ImageView) findViewById(R.id.view4); img5 = (ImageView) findViewById(R.id.view5); Bitmap bit = BitmapFactory.decodeResource(getResources(), R.drawable.bb); Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(bit, thumbsize, thumbsize); img1.setImageBitmap(ThumbImage); Bitmap bit2 = BitmapFactory.decodeResource(getResources(), R.drawable.aa); Bitmap ThumbImage2 = ThumbnailUtils.extractThumbnail(bit2, thumbsize, thumbsize); img2.setImageBitmap(ThumbImage2); Bitmap bit3 = BitmapFactory.decodeResource(getResources(), R.drawable.aa); Bitmap ThumbImage3 = ThumbnailUtils.extractThumbnail(bit3, thumbsize, thumbsize); img3.setImageBitmap(ThumbImage3); Bitmap bit4 = BitmapFactory.decodeResource(getResources(), R.drawable.cc); Bitmap ThumbImage4 = ThumbnailUtils.extractThumbnail(bit4, thumbsize, thumbsize); img4.setImageBitmap(ThumbImage4); Bitmap bit5 = BitmapFactory.decodeResource(getResources(), R.drawable.hh); Bitmap ThumbImage5 = ThumbnailUtils.extractThumbnail(bit5, thumbsize, thumbsize); img5.setImageBitmap(ThumbImage5); }
/** * Called to fetch the artist or ablum art. * * @param key The unique identifier for the image. * @param artistName The artist name for the Last.fm API. * @param albumName The album name for the Last.fm API. * @param albumId The album art index, to check for missing artwork. * @param imageView The {@link ImageView} used to set the cached {@link Bitmap}. * @param imageType The type of image URL to fetch for. */ protected void loadImage( final String key, final String artistName, final String albumName, final long albumId, final ImageView imageView, final ImageType imageType) { if (key == null || mImageCache == null || imageView == null) { return; } // First, check the memory for the image final Bitmap lruBitmap = mImageCache.getBitmapFromMemCache(key); if (lruBitmap != null && imageView != null) { // Bitmap found in memory cache imageView.setImageBitmap(lruBitmap); } else if (executePotentialWork(key, imageView) && imageView != null && !mImageCache.isDiskCachePaused()) { // Otherwise run the worker task final BitmapWorkerTask bitmapWorkerTask = new BitmapWorkerTask(imageView, imageType); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mDefault, bitmapWorkerTask); imageView.setImageDrawable(asyncDrawable); try { ApolloUtils.execute( false, bitmapWorkerTask, key, artistName, albumName, String.valueOf(albumId)); } catch (RejectedExecutionException e) { // Executor has exhausted queue space, show default artwork imageView.setImageBitmap(getDefaultArtwork()); } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { final ImageView imageView; if (convertView == null) { imageView = new ImageView(context); convertView = imageView; convertView.setTag(imageView); } else { imageView = (ImageView) convertView.getTag(); } imageView.setImageResource(R.drawable.default_img); String imgUrl = imageUrls.get(position); if (CacheUtil.getInstence().iSCacheFileExists(imgUrl)) { imageView.setImageBitmap(AndroidFileUtils.getBitmap(imgUrl, 400, 400)); } else { if (imgUrl != null && !imgUrl.equals("")) { Bitmap bitmap = LocalImageCache.get() .loadImageBitmap( CacheUtil.avatarCachePath + imgUrl.substring(imgUrl.lastIndexOf("/"))); if (bitmap == null) { // new NetImageTask(imageView).execute(position); AppData.volleyUtil.loadImageByVolley( ChatServerConstant.URL.SERVER_HOST + imgUrl, imageView, R.drawable.default_img, R.drawable.default_img); } else { imageView.setImageBitmap(bitmap); } } } return convertView; }
/** 对拖拽图片不同的点击事件处理 */ @Override public boolean onTouchEvent(MotionEvent event) { int X = (int) event.getX(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: dragBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.lock_touch); heartView.setImageBitmap(dragBitmap); linearLayoutL.setBackgroundResource(R.drawable.left_bg_default); linearLayoutR.setBackgroundResource(R.drawable.left_bg_default); locationX = (int) event.getX(); Log.i(TAG, "是否点击到位=" + isActionDown(event)); return isActionDown(event); // 判断是否点击了滑动区�? case MotionEvent.ACTION_MOVE: // 保存x轴方向,绘制图画 locationX = X; invalidate(); // 重新绘图 return true; case MotionEvent.ACTION_UP: // 判断是否解锁成功 dragBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_slide_circle_n); heartView.setImageBitmap(dragBitmap); linearLayoutL.setBackgroundColor(getResources().getColor(R.color.transparent)); linearLayoutR.setBackgroundResource(getResources().getColor(R.color.transparent)); if (!unLockLeft() && !unLockRight()) { // 没有解锁成功,动画应该回滚 flag = false; handleActionUpEvent(event); // 动画回滚 } return true; } return super.onTouchEvent(event); }
private void setLinePositions(GridLayoutView glv) { // extend imgageView to bounds Bitmap bitmapy = BitmapFactory.decodeResource(getResources(), R.drawable.line_y); bitmapy = Bitmap.createScaledBitmap(bitmapy, glWidth, bitmapy.getHeight(), true); lineY.setImageBitmap(bitmapy); Bitmap bitmapx = BitmapFactory.decodeResource(getResources(), R.drawable.line_x); bitmapx = Bitmap.createScaledBitmap(bitmapx, bitmapx.getWidth(), glHeight, true); lineX.setImageBitmap(bitmapx); xParams = (RelativeLayout.LayoutParams) lineX.getLayoutParams(); yParams = (RelativeLayout.LayoutParams) lineY.getLayoutParams(); int positionLineXCentre = glv.getAxisXlines().get(glv.getGridSize() / 2).x; xParams.leftMargin = shapeStartPointX(glv.getZeroPosX(), glv.getLineSpacingX(), lineStartCoordX) - bitmapx.getWidth() / 2; lineX.setLayoutParams(xParams); int positionLineYCentre = glv.getAxisYlines().get(glv.getGridSize() / 2).y; yParams.topMargin = shapeStartPointY(glv.getZeroPosY(), glv.getLineSpacingY(), lineStartCoordY) - bitmapy.getHeight() / 2; lineY.setLayoutParams(yParams); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CAMERA) { // 拍照返回 if (resultCode == RESULT_OK) { handleBigCameraPhoto(); } } else if (requestCode == REQUEST_PICK) { Uri uri = data.getData(); Log.d("way", "uri: " + uri); try { // Bitmap bitmap = // MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri); // mImageView.setImageURI(uri); String path = GetPathFromUri4kitkat.getPath(this, uri); Bitmap bitmap = getBitmap(path, true); mImageView.setImageBitmap(bitmap); mImageView.setImageBitmap(bitmap); } catch (Exception e) { e.printStackTrace(); } // goCropActivity(uri); } Toast.makeText(MainActivity.this, "onActivityResult", Toast.LENGTH_SHORT).show(); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); if (resultCode == getActivity().RESULT_OK) { if (requestCode == SELECT_PHOTO) { final boolean isCamera; if (data == null) { isCamera = true; } else { final String action = data.getAction(); if (action == null) { isCamera = false; } else { isCamera = action.equals(MediaStore.ACTION_IMAGE_CAPTURE); } } Uri selectedImageUri; if (isCamera) { selectedImageUri = outputFileUri; // Bitmap factory BitmapFactory.Options options = new BitmapFactory.Options(); // downsizing image as it throws OutOfMemory Exception for larger // images options.inSampleSize = 8; final Bitmap bitmap = BitmapFactory.decodeFile(selectedImageUri.getPath(), options); // v.imageView.setImageDrawable(roundedImage); currentImageView.setImageBitmap(bitmap); // imageProfile.setImageBitmap(bitmap); // imageCompany.setImageBitmap(bitmap); } else { selectedImageUri = data == null ? null : data.getData(); Log.d("ImageURI", selectedImageUri.getLastPathSegment()); // /Bitmap factory BitmapFactory.Options options = new BitmapFactory.Options(); // downsizing image as it throws OutOfMemory Exception for larger // images options.inSampleSize = 8; try { // Using Input Stream to get uri InputStream input = getActivity().getContentResolver().openInputStream(selectedImageUri); final Bitmap bitmap = BitmapFactory.decodeStream(input); // imageProfile.setImageBitmap(bitmap); currentImageView.setImageBitmap(bitmap); } catch (FileNotFoundException e) { e.printStackTrace(); } } } } else if (resultCode == getActivity().RESULT_CANCELED) { // user cancelled Image capture Toast.makeText(getActivity(), "User cancelled image capture", Toast.LENGTH_SHORT).show(); } else { // failed to capture image Toast.makeText(getActivity(), "Sorry! Failed to capture image", Toast.LENGTH_SHORT).show(); } }
public void startAnimation() { if (item == null) { return; } foregroundImage = new ImageView(context); if (item.getForeground().getColor() != null) { foregroundImage.setBackgroundColor(Color.parseColor(item.getForeground().getColor())); } if (item.getForeground().getImage() != null) { try { FileInputStream fileInputStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "1.png"); Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream); foregroundImage.setImageBitmap(bitmap); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } } AbsoluteLayout.LayoutParams foregroundParams = new AbsoluteLayout.LayoutParams( item.getGeometry().getWidth(), item.getGeometry().getHeight(), item.getGeometry().getLeft(), item.getGeometry().getTop()); foregroundImage.setLayoutParams(foregroundParams); layout.addView(foregroundImage); backgroundImage = new ImageView(context); if (item.getBackground().getColor() != null) { backgroundImage.setBackgroundColor(Color.parseColor(item.getBackground().getColor())); } if (item.getBackground().getImage() != null) { try { FileInputStream fileInputStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "1.png"); Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream); backgroundImage.setImageBitmap(bitmap); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } } AbsoluteLayout.LayoutParams backgroundParams = new AbsoluteLayout.LayoutParams( item.getGeometry().getWidth(), item.getGeometry().getHeight(), item.getGeometry().getLeft(), item.getGeometry().getTop()); backgroundImage.setLayoutParams(backgroundParams); AlphaAnimation animation = new AlphaAnimation(0f, 1.0f); animation.setDuration(item.getDuration() * 1000); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); backgroundImage.startAnimation(animation); layout.addView(backgroundImage); }
private void bindDrawableResources() { mBitmapCache = new SparseArray<Bitmap>(); ImageView openMrsLogoImage = (ImageView) findViewById(R.id.openmrsLogo); createImageBitmap(R.drawable.openmrs_logo, openMrsLogoImage.getLayoutParams()); ImageView urlEdit = (ImageView) findViewById(R.id.urlEdit); createImageBitmap(R.drawable.ico_edit, urlEdit.getLayoutParams()); openMrsLogoImage.setImageBitmap(mBitmapCache.get(R.drawable.openmrs_logo)); urlEdit.setImageBitmap(mBitmapCache.get(R.drawable.ico_edit)); }
private void handleAvatar(ImageView avatarIV, ThreadRowInfo row) { final int lou = row.getLou(); final String avatarUrl = FunctionUtil.parseAvatarUrl(row.getJs_escap_avatar()); // final String userId = String.valueOf(row.getAuthorid()); if (PhoneConfiguration.getInstance().nikeWidth < 3) { avatarIV.setImageBitmap(null); return; } if (defaultAvatar == null || defaultAvatar.getWidth() != PhoneConfiguration.getInstance().nikeWidth) { Resources res = avatarIV.getContext().getResources(); InputStream is = res.openRawResource(R.drawable.default_avatar); InputStream is2 = res.openRawResource(R.drawable.default_avatar); this.defaultAvatar = ImageUtil.loadAvatarFromStream(is, is2); } Object tagObj = avatarIV.getTag(); if (tagObj instanceof AvatarTag) { AvatarTag origTag = (AvatarTag) tagObj; if (origTag.isDefault == false) { ImageUtil.recycleImageView(avatarIV); // Log.d(TAG, "recycle avatar:" + origTag.lou); } else { // Log.d(TAG, "default avatar, skip recycle"); } } AvatarTag tag = new AvatarTag(lou, true); avatarIV.setImageBitmap(defaultAvatar); avatarIV.setTag(tag); if (!StringUtil.isEmpty(avatarUrl)) { final String avatarPath = ImageUtil.newImage(avatarUrl, userId); if (avatarPath != null) { File f = new File(avatarPath); if (f.exists() && !isPending(avatarUrl)) { Bitmap bitmap = ImageUtil.loadAvatarFromSdcard(avatarPath); if (bitmap != null) { avatarIV.setImageBitmap(bitmap); tag.isDefault = false; } else f.delete(); long date = f.lastModified(); if ((System.currentTimeMillis() - date) / 1000 > 30 * 24 * 3600) { f.delete(); } } else { final boolean downImg = isInWifi() || PhoneConfiguration.getInstance().isDownAvatarNoWifi(); new AvatarLoadTask(avatarIV, null, downImg, lou, this) .execute(avatarUrl, avatarPath, userId); } } } }
public void setVisibility(int visibility) { super.setVisibility(visibility); if (visibility != VISIBLE) { iv.setImageBitmap(null); iv.setTag(null); ivPlaceHolder.setImageBitmap(null); vFrom = null; } };
public void DisplayImage(String productid, Activity activity, ImageView imageView) { imageViews.put(imageView, productid); Bitmap bitmap = memoryCache.get(productid); if (bitmap != null) { imageView.setImageBitmap(bitmap); } else { queuePhoto(productid, activity, imageView); imageView.setImageBitmap(null); } }
private void getperBg() { if (bgBitmap == null) { bgBitmap = PhotoUtils.getListHeadBg(); if (null != bgBitmap) { headbg.setImageBitmap(bgBitmap); } } else { headbg.setImageBitmap(bgBitmap); } }
private void refreshImages() { if (picOne.exists()) { Bitmap myBitmap = BitmapFactory.decodeFile(picOne.getAbsolutePath()); imgThis.setImageBitmap(myBitmap); } if (picTwo.exists()) { Bitmap myBitmap = BitmapFactory.decodeFile(picTwo.getAbsolutePath()); imgThat.setImageBitmap(myBitmap); } }
public void goodsshownext() { imageView10 = (ImageView) findViewById(R.id.imageview10); imageView11 = (ImageView) findViewById(R.id.imageview11); imageView12 = (ImageView) findViewById(R.id.imageview12); imageView13 = (ImageView) findViewById(R.id.imageview13); imageView14 = (ImageView) findViewById(R.id.imageview14); imageView15 = (ImageView) findViewById(R.id.imageview15); imageView16 = (ImageView) findViewById(R.id.imageview16); imageView17 = (ImageView) findViewById(R.id.imageview17); imageView18 = (ImageView) findViewById(R.id.imageview18); imageView10.setImageBitmap(goodsdata.bit(image[t + 0])); imageView11.setImageBitmap(goodsdata.bit(image[t + 1])); imageView12.setImageBitmap(goodsdata.bit(image[t + 2])); imageView13.setImageBitmap(goodsdata.bit(image[t + 3])); imageView14.setImageBitmap(goodsdata.bit(image[t + 4])); imageView15.setImageBitmap(goodsdata.bit(image[t + 5])); imageView16.setImageBitmap(goodsdata.bit(image[t + 6])); imageView17.setImageBitmap(goodsdata.bit(image[t + 7])); imageView18.setImageBitmap(goodsdata.bit(image[t + 8])); imageView10.setOnClickListener(goodsIntroduce2); imageView11.setOnClickListener(goodsIntroduce2); imageView12.setOnClickListener(goodsIntroduce2); imageView13.setOnClickListener(goodsIntroduce2); imageView14.setOnClickListener(goodsIntroduce2); imageView15.setOnClickListener(goodsIntroduce2); imageView16.setOnClickListener(goodsIntroduce2); imageView17.setOnClickListener(goodsIntroduce2); imageView18.setOnClickListener(goodsIntroduce2); }
public void goodsshowmain() { imageView1 = (ImageView) findViewById(R.id.imageview1); imageView2 = (ImageView) findViewById(R.id.imageview2); imageView3 = (ImageView) findViewById(R.id.imageview3); imageView4 = (ImageView) findViewById(R.id.imageview4); imageView5 = (ImageView) findViewById(R.id.imageview5); imageView6 = (ImageView) findViewById(R.id.imageview6); imageView7 = (ImageView) findViewById(R.id.imageview7); imageView8 = (ImageView) findViewById(R.id.imageview8); imageView9 = (ImageView) findViewById(R.id.imageview9); imageView1.setImageBitmap(goodsdata.bit(image[t + 0])); imageView2.setImageBitmap(goodsdata.bit(image[t + 1])); imageView3.setImageBitmap(goodsdata.bit(image[t + 2])); imageView4.setImageBitmap(goodsdata.bit(image[t + 3])); imageView5.setImageBitmap(goodsdata.bit(image[t + 4])); imageView6.setImageBitmap(goodsdata.bit(image[t + 5])); imageView7.setImageBitmap(goodsdata.bit(image[t + 6])); imageView8.setImageBitmap(goodsdata.bit(image[t + 7])); imageView9.setImageBitmap(goodsdata.bit(image[t + 8])); imageView1.setOnClickListener(goodsIntroduce); imageView2.setOnClickListener(goodsIntroduce); imageView3.setOnClickListener(goodsIntroduce); imageView4.setOnClickListener(goodsIntroduce); imageView5.setOnClickListener(goodsIntroduce); imageView6.setOnClickListener(goodsIntroduce); imageView7.setOnClickListener(goodsIntroduce); imageView8.setOnClickListener(goodsIntroduce); imageView9.setOnClickListener(goodsIntroduce); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, // WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_game); btn_popWindow = (Button) findViewById(R.id.button3); iv_after = (ImageView) findViewById(R.id.iv_after); iv_before = (ImageView) findViewById(R.id.iv_before); et_size = (EditText) findViewById(R.id.et_size); pop = (LinearLayout) findViewById(R.id.pop); after = BitmapFactory.decodeResource(getResources(), R.drawable.before); // Ö»¶ÁµÄbitmap before = BitmapFactory.decodeResource(getResources(), R.drawable.after); iv_after.setImageBitmap(after); iv_before.setImageBitmap(before); // ¿ÉÒÔÐ޸ĵĿհ×bitmap alterBitmap = Bitmap.createBitmap(before.getWidth(), before.getHeight(), before.getConfig()); canvas = new Canvas(alterBitmap); paint = new Paint(); paint.setStrokeWidth(5); paint.setColor(Color.BLACK); canvas.drawBitmap(before, new Matrix(), paint); iv_before.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: int newX = (int) event.getX(); int newY = (int) event.getY(); for (int i = -radio; i < radio; i++) { for (int j = -radio; j < radio; j++) { int x = i + newX; int y = j + newY; // ¼ÆËã°ë¾¶ int r = (int) Math.sqrt(i * i + j * j); // ÅжÏËù´¥ÃþµãÔÚͼƬ·¶Î§ÄÚ£¬²¢ÇÒÐ޸IJ¿·ÖΪԲÐÎ if (x > 0 && x < iv_before.getWidth() && y > 0 && y < iv_before.getHeight() && r <= radio) { alterBitmap.setPixel(x, y, Color.TRANSPARENT); } } } iv_before.setImageBitmap(alterBitmap); break; } return true; } }); }