Image Pixelation (PNG)

by nimph » Sat, 05 Sep 2009 09:44:16 GMT


Sponsored Links
 I'm trying to load a PNG image into an ImageView using the following
code:

    mImageView.setImageBitmap(BitmapFactory.decodeStream(getClass().
           getResourceAsStream("file_name.png")));

The images are displayed just fine, but they are badly pixelated.

Putting the images in 'res/drawables' works fine, I only see this with
images loaded from the file-system.

What am I doing wrong?  Let me know if you need more info.

Thanks,
--~--~---------~--~----~------------~-------~--~----~



Image Pixelation (PNG)

by String » Sat, 05 Sep 2009 11:35:07 GMT


 I've had this problem if the size of the ImageView doesn't exactly
match the dimensions of the bitmap in the file.

String



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Image Pixelation (PNG)

by nimph » Sun, 06 Sep 2009 12:46:43 GMT


 Thanks, had not tried that, but...  No luck...

I tried adding the following to the ImageView.

    android:maxHeight="32px" android:maxWidth="32px"
android:minHeight="32px"
                android:minWidth="32px"

Are these the attributes you set?

//




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Read sent sms in inbox with 10 min interval

Hello,

So I'm working on an app that should read sent sms in inbox for every
10 min.
I use a logic to compare the device's time and the time sms is sent.
And if the time sms is sent > the time of the device the toast will
pop up and show the sms
But I can't get the result I want, the toast is always giving the same
sms all the time.
So could anyone help me?

Here is my code:

package com.sent.sms;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;

public class SentSMS extends Service{
        int saveDate = 0;
    int saveMonth = 0;
    int saveYear = 0;

    int saveHour = 0;
    int saveMinute = 0;
    int saveSecond = 0;

    int date = 0;
    int month = 0;
    int year = 0;

    int hours = 0;
    int minutes = 0;
    int seconds = 0;

    String[] projection = new String[]{"_id", "address", "body",
"date"};
    Uri uriSMSURI = Uri.parse("content://sms/sent");

    private Context ctx;

    private static Timer timer = new Timer();

        @Override
        public void onCreate() {
                super.onCreate();
                ctx = this;
                timer.scheduleAtFixedRate(new mainTask(), 0,60000);
        }

        @Override
        public IBinder onBind(Intent intent) {
                return null;
        }

        private class mainTask extends TimerTask{
        public void run(){
                doAllThing.sendEmptyMessage(0);
        }
    }

        private final Handler doAllThing = new Handler(){
        @Override
        public void handleMessage(Message msg){
                checkSMS();
                saveTime();
        }
    };

        private void saveTime(){
            date = Calendar.getInstance().get(Calendar.DATE);
            month = Calendar.getInstance().get(Calendar.MONTH)+1;
            year = Calendar.getInstance().get(Calendar.YEAR);
        hours = new Date().getHours();
        minutes = new Date().getMinutes();
        seconds = new Date().getSeconds();
        }

        public void checkSMS(){
              String sms = "";
              Cursor cursor = null;

              try {
                    cursor = getContentResolver().query(uriSMSURI
                            , projection
                            , null //selection
                            , null //selectionArgs
                            , null); //sortOrder

                    if (cursor != null && cursor.moveToFirst()) {
                        do {
                            String to =
cursor.getString(cursor.getColumnIndex("address"));
                            String body =
cursor.getString(cursor.getColumnIndex("body"));

                            String dateSMS =
cursor.getString(cursor.getColumnIndex("date"));
                            String monthSMS =
cursor.getString(cursor.getColumnIndex("date"));
                            String yearSMS =
cursor.getString(cursor.getColumnIndex("date"));

                            String hourSMS =
cursor.getString(cursor.getColumnIndex("date"));
                            String minuteSMS =
cursor.getString(cursor.getColumnIndex("date"));
                            String secondSMS =
cursor.getString(cursor.getColumnIndex("date"));

                            SimpleDateFormat formatDate = new
SimpleDateFormat("d");
                            SimpleDateFormat formatMonth = new
SimpleDateFormat("M");
                            SimpleDateFormat formatYear = new
SimpleDateFormat("yyyy");

                            SimpleDateFormat formatHour = new
SimpleDateFormat("H");
                            SimpleDateFormat formatMinute = new
SimpleDateFormat("m");
                            SimpleDateFormat formatSecond = new
SimpleDateFormat("s");

                            dateSMS = formatDate.format(new
Date(Long.parseLong(dateSMS)));
                            monthSMS = formatMonth.format(new
Date(Long.parseLong(monthSMS)));
                            yearSMS = formatYear.format(new
Date(Long.parseLong(yearSMS)));

                            hourSMS = formatHour.format(new
Date(Long.parseLong(hourSMS)));
                            minuteSMS = formatMinute.format(new
Date(Long.parseLong(minuteSMS)));
                            secondSMS = formatSecond.format(new
Date(Long.parseLong(secondSMS)));

                            saveDate = Integer.parseInt(dateSMS.trim());
                            saveMonth = Integer.parseInt(monthSMS.trim());
                            saveYear = Integer.parseInt(yearSMS.trim());

                            saveHour = Integer.parseInt(hourSMS.trim());
                            saveMinute = Integer.parseInt(minuteSMS.trim());
                            saveSecond = Integer.parseInt(secondSMS.trim());

                            if(date == 0 && month == 0 && year == 0 && hours ==
0 && minutes == 0 && seconds == 0){
                                sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                            }else{

                                if(saveMinute > minutes){
                                        sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                                    }else if(saveHour > hours){
                                        sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                                    }else if(saveDate > date){
                                        sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                                    }else if(saveMonth > month){
                                        sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                                    }else if(saveYear > year){
                                        sms += 
"Time:"+saveDate+"/"+saveMonth+"/"+saveYear
+"/"+" - "+saveHour+":"+saveMinute+":"+saveSecond+"To:"+to+"Body:"+body
+"\n";
                                    }
                            }
                        } while (cursor.moveToNext());
                    }
                } finally {
                    if (cursor != null) {
                        cursor.close();
                }
            }
                Toast.makeText(this, sms,Toast.LENGTH_LONG).show();
        }
}

Thank you very much.
Sorry for the long post :)

-- 

2. Hide My Files from Another Application

Hello Everyone.

In my application i m downloading some (mp4 or mp3 ) files from the
internet. Now i want to hide those files from any other application
like(Astro any Music player) so how can i do this ?

Please help me....

-- 

3. Facebook using Widget ?

4. GIF image download

5. how android application connect with the pc connected by usb

6. Unable to start a service from a Broadcast Receiver

7. Missing constructor in Audio Effects API?