Has anyone else encountered this problem?

On Thu, Jul 21, 2011 at 7:54 PM, Simon Platten <[email protected]
> wrote:

> I have a listview with each item defined as:
>
> <?xml version="1.0" encoding="utf-8"?>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
>                      android:layout_width="fill_parent"
>
>  android:layout_height="?android:attr/listPreferredItemHeight"
>                      android:padding="10dp">
>     <LinearLayout android:id="@+id/llHeader"
>                       android:background="@color/blue"
>                       android:orientation="vertical"
>                       android:layout_alignParentTop="true"
>                       android:layout_width="fill_parent"
>                       android:layout_height="fill_parent" >
>         <CheckBox android:id="@+id/chkUse"
>                      android:text="File-name"
>                       android:textColor="@color/yellow"
>                       android:textStyle="bold"
>                      android:layout_width="fill_parent"
>                      android:layout_height="wrap_content"
>                       android:layout_gravity="left" />
>     </LinearLayout>
>     <ImageView android:id="@+id/ivthumbNail"
>                   android:src="@drawable/placeholder"
>                   android:layout_centerHorizontal="true"
>                   android:layout_below="@+id/llHeader"
>                   android:layout_width="fill_parent"
>                   android:layout_height="fill_parent" />
>     <ImageButton android:id="@+id/btnCCW"
>                      android:src="@drawable/ccw_rotate_btn"
>                     android:layout_alignLeft="@+id/llHeader"
>                        android:layout_below="@+id/llHeader"
>                      android:layout_width="48dip"
>                     android:layout_height="48dip" />
>     <ImageButton android:id="@+id/btnCW"
>                      android:src="@drawable/cw_rotate_btn"
>                     android:layout_alignRight="@+id/llHeader"
>                     android:layout_below="@+id/llHeader"
>                      android:layout_width="48dip"
>                     android:layout_height="48dip" />
> </RelativeLayout>
>
>
> This gives a title / checkbox, under this is an imageview with a button
> either side of it.  With the buttons I can rotate the image clockwise or
> counter clockwise by 90 degrees, the routine that performs the rotation and
> scaling of the images:
>
>     public Bitmap scaleAndRotateImage(boolean blnShow) {
>         try{
>             BitmapFactory.Options bfo = new BitmapFactory.Options();
>             bfo.inSampleSize = 4;
>             Bitmap bmpData = BitmapFactory.decodeFile(m_strFilename,
> bfo);
>
>             if ( m_intOriginalWidth == 0 && m_intOriginalHeight == 0 ) {
>                 m_intOriginalWidth = bmpData.getWidth();
>                 m_intOriginalHeight = bmpData.getHeight();
>                 int intScaledWidth = clsWallpaper.m_intScrWidth;
>                 float fltAspectRatio = (float)bmpData.getHeight() /
> (float)bmpData.getWidth();
>                 int intScaledHeight = (int)((float)intScaledWidth *
> fltAspectRatio);
>                 m_fltScaleWidth = ((float)intScaledWidth) /
> ((float)m_intOriginalWidth);
>                 m_fltScaleHeight = ((float)intScaledHeight) /
> ((float)m_intOriginalHeight);
>             }
> // Apply the scale to the matrix
>             Matrix mtx = new Matrix();
>             mtx.postScale(m_fltScaleWidth, m_fltScaleHeight);
> // Apply the rotation angle to the matrix
>             mtx.postRotate(m_intTotalAngle);
> // Get the scaled and maybe rotated version of the bitmap
>             Bitmap bmpScaled = Bitmap.createBitmap(bmpData,
>                                                     0, 0,
>                                                     m_intOriginalWidth,
>                                                     m_intOriginalHeight,
>                                                     mtx, true);
>             if ( blnShow == true && bmpScaled != null ) {
>                 m_drwThumbnail = new BitmapDrawable(bmpScaled);
>                 Activity a = (Activity)m_ivThumbnail.getContext();
>                 a.runOnUiThread(updateThumbnail);
>             }
>             return bmpScaled;
>         } catch( Exception ex ) {
>             Log.e( TAG, "rotateThumbnail", ex );
>         }
>         return null;
>     }
>
> The strange this is when the image is rotated the scaled version is smaller
> than it is supposed to be, if I scroll the listview so the item goes out of
> view then scroll it back into view the item comes back with the image of the
> correct size.  Is they're anything I can do about this?
> --
> Regards,
> Sy
>
>


-- 
Regards,
Sy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to