TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 04:20:29 GMT


Sponsored Links
 I'm using a TransitionDrawable to draw a series of bitmaps in an ImageView.
Every time my scheduled handler ticks over, i replace the bitmaps.

I'm finding that if they are not the same size, the draw splits the 
difference for the second bitmap using the first bitmap (at least I think 
thats whats going on).

I was thinking that I might use two bitmaps there were the same size as a 
base, then draw my actual jpeg's onto those so the TransitionDrawable 
doesn't try and scale them.

Is there a better way to do this?

-- 



Re: TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 12:24:42 GMT


 An update to this problem.
It seems the issue is related to ImageView's automatic scaling somehow.
it *looks* as if the TransitionDrawable needs both images to be the same 
size... or maybe ImageView does it.
The symptom is that it divides the difference in width between the to images 
(i.e. an image in landscape and one in portrait so you get one squashed and 
one stretched).


-- 


Sponsored Links


Re: Re: TransitionDrawable with different sized bitmaps

by Dianne Hackborn » Fri, 20 May 2011 12:36:58 GMT


 The images need to be the same.  Generally widgets don't like nor have a way
to deal with drawable dimensions changing out from under them.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Re: Re: TransitionDrawable with different sized bitmaps

by Brill Pappin » Fri, 20 May 2011 12:46:47 GMT


 The funny thing is how its actually handling it. Both parts of the 
transition are getting scaled.

What i'm doing is cycling through images from the MediaResolver (like camera 
shots) and crossfading between them.
Do you have any suggestions for other ways to do that?

At the moment I'm playing around with creating a "template" bitmap that is 
used to draw everything onto, then give it to the ImageView, but I'm not 
feeling all that good about the solution so far.

-- 



Re: Re: TransitionDrawable with different sized bitmaps

by Dianne Hackborn » Fri, 20 May 2011 15:10:21 GMT


 You could write your own Drawable that keeps its size consistent across the
images and does whatever transition you want.  Or use a ViewFlipper to swap
between ImageViews.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 



Other Threads

1. AudioRecord problem

Did any one try code of sipdroid given in [url]http://sipdroid.org/[/
url]. If yes than please help me. I have to read samples from
microphone and send it to udp socket. For this I'm using AudioRecord
class as given in RtpStreamSender.java and I have use read method to
read the samples which is given below:
public int read (byte[] audioData, int offsetInBytes, int
sizeInBytes).This method reads audio data from the audio hardware for
recording into a buffer.
Its Parameters are :
 audioData :the array to which the recorded audio data is written.
offsetInBytes: index in audioData from which the data is written
expressed in bytes.
sizeInBytes :the number of requested bytes.

It Returns:
 the number of bytes that were read or or ERROR_INVALID_OPERATION if
the object wasn't properly initialized, or ERROR_BAD_VALUE if the
parameters don't resolve to valid data and indexes. The number of
bytes will not exceed sizeInBytes.

I have written this method in my code like this :
int num;
byte[] buf = new byte[160]; num = record.read(buf, 0, 160);

The problem is that it always returns 160 (i.e. the requested byte to
be read) not less than 160 even if the data is not available. I am
getting voice sample from microphone and My sampling rate is 8000 Hz
so 8000 samples per second encoding in 16 bit so to read 160 byte it
requires at least 10 milliseconds but it send data at every 1 ms. If
it is a blocking method than it should return the value 160 after
reading 160 bytes. Why it returns maximum value even if it reads
10-20bytes ? what's the problem? please help me. Thanks in advance.
My code is like :
public void run()
{
running = true;
int frame_size = 160;
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
  try
 {
 minBuffersize= AudioRecord.getMinBufferSize(8000,
AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT);
   Log.i(TAG, "trying to capture " + String.format("%d", frameSize) +
" bytes");
   record = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000,
AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT,
20000);
   record.startRecording();
   byte[] buffer = new byte[frameSize];
   while (running)
  {
     record.read(buffer, 0, frameSize);
     Log.i(TAG, "Captured " + String.format("%d", frameSize) + " bytes
of audio");
  }
 }
 catch (Exception e)
 { Log.e(TAG, "Failed to capture audio"); }
}

-- 

2. getting other ScanResults fields

Hallo,
i wanted to get some other ScanResults fields from android.net.wifi
packet. Like vendor_specific or other 802.11 beacon frame EIDs.
Could somebody give me a hint where to start?
I'm using HTC Desire Android 2.1

thanks

best regards

neaiskus

-- 

3. Google MAP API and Internal GPS support

4. Calling setColorFilter on an ImageView causes it to disappear in Android 2.2+

5. Use different SoftKeyboard IME on some specific fields?

6. Default keyboard in application

7. Package Missing 2.3 Sample Application