android-bitmap

Performance issue downloading images for RecyclerView

家住魔仙堡 提交于 2019-12-02 07:53:55
问题 I have a ListView with a custom adapter. Every row has an ImageView that I render using a Bitmap, but my current code blocks the UI thread as I am using get() after executing my AsyncTask that downloads the bitmaps. I would like to change my code and access the imageViews in the onPostExecute() or something similar. So that the rows already display without waiting for all sprites to load. Adapter class (download is triggered here) public class PokemonAdapter extends ArrayAdapter<PokemonPOJO>

Get images from PHP-MySql server to Android using json

泪湿孤枕 提交于 2019-12-02 07:49:40
i am devloping an application which download image from php-server and display image in image view ..but when i receive image from php page if (!empty($result)) { if (mysql_num_rows($result) > 0) { $result = mysql_fetch_array($result); $user = array(); $user["image"] = base64_encode($result["image"]); $response["success"] = 1; $response["image_table"] = array(); array_push($response["image_table"], $user); echo json_encode($response); } else { $response["success"] = 0; $response["message"] = "No Image found"; echo json_encode($response); } it gives me json response like this 03-30 04:43:44.013

OutOfMemory while setting image in ImageView

别来无恙 提交于 2019-12-02 05:12:07
问题 I am setting help screens images at 4 different places in my app. The activity code is the following- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_list); int screenType = getIntent().getIntExtra("screenName", 0); ImageView imageView = (ImageView) findViewById(R.id.help_image); switch (screenType) { case 1: imageView.setImageResource(R.drawable.help0); break; case 2: imageView.setImageResource(R.drawable.help1);

Android: How do I scale a bitmap to fit the screen size using canvas/draw bitmap?

雨燕双飞 提交于 2019-12-02 03:24:21
问题 I am taking an image and drawing it to the screen using canvas. I want to scale it based on the screen size. This is what I tried, but it cuts off a large chunk of the image: DisplayMetrics metrics = context.getResources().getDisplayMetrics(); int width = metrics.widthPixels; int height = metrics.heightPixels; Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.myimage); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); Rect frameToDraw = new Rect(0,

OutOfMemory while setting image in ImageView

最后都变了- 提交于 2019-12-02 02:19:36
I am setting help screens images at 4 different places in my app. The activity code is the following- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help_list); int screenType = getIntent().getIntExtra("screenName", 0); ImageView imageView = (ImageView) findViewById(R.id.help_image); switch (screenType) { case 1: imageView.setImageResource(R.drawable.help0); break; case 2: imageView.setImageResource(R.drawable.help1); break; case 3: imageView.setImageResource(R.drawable.help2); break; case 4: imageView.setImageResource

Android: How do I scale a bitmap to fit the screen size using canvas/draw bitmap?

我与影子孤独终老i 提交于 2019-12-02 01:31:24
I am taking an image and drawing it to the screen using canvas. I want to scale it based on the screen size. This is what I tried, but it cuts off a large chunk of the image: DisplayMetrics metrics = context.getResources().getDisplayMetrics(); int width = metrics.widthPixels; int height = metrics.heightPixels; Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.myimage); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); Rect frameToDraw = new Rect(0, 0, width, height); RectF whereToDraw = new RectF(0, 0, width, height); canvas.drawBitmap(bitmap

Prevent bitmap too large to be uploaded into a texture android

拟墨画扇 提交于 2019-12-01 15:04:25
I need to display original image in full screen in gallery form. For thumb it will be work perfectly and when I try to display that image in full screen with original source it will not be able to display. In most cases if the image resolution is greater then 2000 then it will display error bitmap too large to be uploaded into a texture android . I want to prevent this, I have search google but not getting any answer regarding this. Phileo99 I came across the same problem and came up with a one liner solution for this problem here : Picasso.with(context).load(new File(path/to/File)).fit()

Set image with rounded corners into ImageView

吃可爱长大的小学妹 提交于 2019-12-01 14:16:42
I have a ListView with contact images and names or numbers. Now I want to round the corners of this contact image. public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; UserHolder holder = null; Log.d("main", "pos:" + "" + position); if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new UserHolder(); holder.Name = (TextView) row.findViewById(R.id.name); holder.Number = (TextView) row.findViewById(R.id.number); holder.img=(ImageView) row

Set image with rounded corners into ImageView

北战南征 提交于 2019-12-01 13:18:20
问题 I have a ListView with contact images and names or numbers. Now I want to round the corners of this contact image. public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; UserHolder holder = null; Log.d("main", "pos:" + "" + position); if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new UserHolder(); holder.Name = (TextView) row.findViewById(R

How to set ImageView to show different position in PNG? (Android sprite alike animations)

不问归期 提交于 2019-12-01 11:47:55
问题 I have the following png: Each Icon is 100X100 px. All in all 800X100 px. I have the following ImageView xml: <ImageView android:id="@+id/CycleStageImage" android:layout_width="100dp" android:layout_height="100dp"> I would like to set CycleStageImage to be show different Icon (100,100) on Timer Interval of 1 Second back and forth. I am having a problem generating a code that moves on Axis of this PNG. I have tried the followings from multiple links over SOF, but with no luck: //first try -