[android-developers] Re: Listing fat-finger-tapped overlays from a MapActivity?

2010-11-01 Thread Mike Reed
Yep, that works, thanks. I didn't realize that onTouchEvent() was
responsible for calling all the overlays onTap()s.

onTouched was a typo -- I wasn't at my dev machine when I posted the
question. The list owner would be any class that had the list as a
data member -- I hadn't written it yet since I had no solution for
this problem yet.

I appreciate the pointers there.

-Mike


On Nov 1, 10:48 am, TreKing treking...@gmail.com wrote:
 On Fri, Oct 29, 2010 at 1:42 PM, Mike Reed waterrock...@gmail.com wrote:
  If I add to a list in the ItemizedOverlay.onTap for each item clicked
  (returning false to not handle), the list owner has no way to know
  when the list is complete (last onTap has been called).

 Who's the list owner?

  I tried onTouched in the MapView,

 There is no onTouched function in MapView, AFAICT.

  Anybody else have an idea of how to solve this?

    1. Create a custom MapView that derives from the base and maintains this
    list of touched items.
    2. Override onTouchEvent, clear your list of touched items, and call
    super.onTouchEvent which calls onTap for all overlays
    3. Each overlay references the MapView that it's in and adds itself to
    that MapView's list of touched items in it's own onTap.
    4. After super.onTouchEvent completes, your MapView has a list of all
    touched overlays

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

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


[android-developers] Listing fat-finger-tapped overlays from a MapActivity?

2010-10-29 Thread Mike Reed
In a map activity, when the user taps more than one item, I need to
produce a list of them, similar to how GoogleEarth works on Android.

If I add to a list in the ItemizedOverlay.onTap for each item clicked
(returning false to not handle), the list owner has no way to know
when the list is complete (last onTap has been called). I tried
onTouched in the MapView, but it's called at first touch. My hope was
that there would be a callback called if none of the onTap() calls
returned true, but there's not.

Anybody else have an idea of how to solve this?

One thought is to fire up a dialog with onTouch, subscribe as a
listener to the onTap calls (set up all the back-end wiring), and have
the dialog's list update dynamically as the onTaps are called. I'm not
sure though that I can keep a dialog updating like that once it's up.

Any other suggestions?

Much appreciated,
Mike

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


[android-developers] Camera preview runs dark on Motorola i1

2010-09-08 Thread Mike Reed
Anyone have any experience with this?

The barcode app, Yelp, and the Google sample app all show the camera
preview as being dark. The camera app that comes with the phone looks
normal, but all other apps that use the Camera.startPreview() code
show up with what looks like a 50% opacity black surface over the
camera image. The top-bar menu is normal brightness, so it's just the
camera image that exhibits this.

I've tried mucking with different Camera.Parameters options, but very
few of these are available in Android 1.5.

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


[android-developers] Re: Camera preview runs dark on Motorola i1

2010-09-08 Thread Mike Reed
Nope, but I did hit that thread while searching. I have started a
similar thread in the Moto Support forums as well though.

I'm developing and need the camera preview to work on this phone. I
figured since it was impacting mainstream apps, some non-developer
solutions might exist. No responses in that arena though, so we'll see
if anyone has any ideas here...

On Sep 8, 3:27 pm, blindfold seeingwithso...@gmail.com wrote:
 Unless it is you under another alias, there is a similar report 
 athttp://www.satelliteguys.us/dishpointer-com-official-support-forum/22...

 Regards

 On Sep 8, 9:47 pm, Mike Reed waterrock...@gmail.com wrote:



  Anyone have any experience with this?

  The barcode app, Yelp, and the Google sample app all show the camera
  preview as being dark. The camera app that comes with the phone looks
  normal, but all other apps that use the Camera.startPreview() code
  show up with what looks like a 50% opacity black surface over the
  camera image. The top-bar menu is normal brightness, so it's just the
  camera image that exhibits this.

  I've tried mucking with different Camera.Parameters options, but very
  few of these are available in Android 1.5.

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


[android-developers] Re: Traceview only getting 5 seconds of data

2010-08-24 Thread Mike Reed
I'm seeing the same thing right now, but it's only 4300ms. One run I
got 3700ms, and another was 4000ms. I have no idea why it's missing so
much.

On Aug 17, 7:17 am, Cleverson clevers...@gmail.com wrote:
 Hi,

 I'm usingtraceviewto identify bottlenecks in my app. If I use the
 emulator, everything works fine. But when the device is used, no
 matter how long I run the app,traceviewonly gets the initial 5
 seconds of my session and nothing more.
 I also noticed an error message in the console:Traceview: (unknown:10301): 
 GLib-WARNING **: g_set_prgname() called
 multiple times

 Have you ever experienced this problem?
 Any tip?
 Thanks in advance!

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


[android-developers] Re: Traceview only getting 5 seconds of data

2010-08-24 Thread Mike Reed
I found that there is a startMethodTracing call that takes a buffer
size, but it gives me an IllegalArgumentException every time.

Anyone have an idea why it won't take startMethodTracing(String, 8,
0); ?


http://developer.android.com/reference/dalvik/system/VMDebug.html#startMethodTracing(java.lang.String,
int, int)


On Aug 23, 5:31 pm, Mike Reed waterrock...@gmail.com wrote:
 I'm seeing the same thing right now, but it's only 4300ms. One run I
 got 3700ms, and another was 4000ms. I have no idea why it's missing so
 much.

 On Aug 17, 7:17 am, Cleverson clevers...@gmail.com wrote:



  Hi,

  I'm usingtraceviewto identify bottlenecks in my app. If I use the
  emulator, everything works fine. But when the device is used, no
  matter how long I run the app,traceviewonly gets the initial 5
  seconds of my session and nothing more.
  I also noticed an error message in the console:Traceview: 
  (unknown:10301): GLib-WARNING **: g_set_prgname() called
  multiple times

  Have you ever experienced this problem?
  Any tip?
  Thanks in advance!

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


[android-developers] onDraw not getting called very often

2010-04-13 Thread Mike Reed
I have a View in which onDraw() is called once at the beginning, and
again about 5 seconds later, then maybe once/minute.

Any ideas what could be causing this? I'm expecting draw calls
continuously.

There is some drawText that is displaying all the time, but it is not
updating unless the once/minute call comes along.

Thanks.

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

To unsubscribe, reply using remove me as the subject.


[android-developers] Re: Antialias transformed bitmap ??

2009-03-03 Thread Mike Reed

antialias will smooth the edges (when drawn at a non-multiple-of-90-degrees)
filtering will smooth the sampled colors within the bitmap

On Tue, Mar 3, 2009 at 7:59 AM, quakeboy prasna...@gmail.com wrote:

 How to draw antialiased bitmap along with transformation matrices.. I
 use matrix to rotate and scale a bitmap and then draw it using
 canvas.drawBitmap

 But the bitmap after the transformation looks ugly and aliased. I
 tried using the paint.antialias(true) and passing it to drawBitmap
 function. It doesn't seem to work.

 Should I set anymore parameters ??
 


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



[android-developers] Re: How to get a region which is not a standard rect area

2009-02-20 Thread Mike Reed

Ah, that's a bug, null should be allowed. I'll see what can be done
there for the future.

The clip parameter is mean to be a hint to speedup turning the path
into a region by restricting the result to a clipped subset of the
path. For your purposes, you can just make a big rectangular region
for the clip. The bounds of the path or larger.

On Thu, Feb 19, 2009 at 10:22 PM, David Hu vistoda...@gmail.com wrote:
  Thanks for your reply, Mike. I've tried your method, seems still not
 work yet. The second parameter of Region.setPath (clip) can't be null.


 If we use null, there will be an exception happen. So I've tried to use
 the region I've just constructed or the original rect region, the area is
 still the ourter standard rect area, not the inclined rect which rotated
 from a standard rect. Here is my code tip and possible result:

  //Calculate region
  top = 150;
  bottom = top + bmp.getHeight(); //bmp is a bitmap instance
  left = 200;
  right = left + bmp.getWidth();
  Path p = new Path();
  p.addRect(left, top, right, bottom, Path.Direction.CCW);

 // use Matrix to rotate 30 degrees
  Matrix mtx = new Matrix();
  mtx.setRotate(30);
  p.transform(mtx);

  Region rgn  = new Region();
  (1)  //- The application will crash here with an exception here
  rgn.setPath(p, null);
  (2)  //- The region is the rect area which encircle the rotated
 rect, not the rotated rect itself
  rgn.setPath(p, rgn);
  (3) //-  The region is the rect area which encircle the rotated
 rect, not the rotated rect itself
  Region clipRgn = new Region(top, bottom, left, right);
  mRgn2.setPath(p, clipRgn);
 BTW, I searched in android source code and www.google.com, can't find any
 usage of this API:

 public boolean setPath(Path path, Region clip)

 So now, my question is which clip region should I pass or any other way in
 order to attain my aim? Hope I've made my aim clearly.

 BR,
 -David

 On Thu, Feb 19, 2009 at 11:27 PM, Mike Reed r...@google.com wrote:

 You could possibly un-rotate your touch-point by 30 degrees, and then
 just use the rectangle.

 However, you can make complex regions by first constructing a Path,
 and then calling region.setPath(...), which converts the path into a
 region. Below is pseudo sample code:

 Path p = new Path();
 p.addRect(rect);// this is your rect
 p.transform(matrix); // construct a matrix and then rotate as you wish
 region.setPath(p, null);

 On Thu, Feb 19, 2009 at 5:01 AM,  vistoda...@gmail.com wrote:
 
I want to judge whether the touch point(x, y) is in a region or
  not, the region is from a stardard rect by rotating specified degrees,
  from example, rotate 30 degrees. There is a class named Region in
  Android, but as I researched, it just supports standard rect, is there
  any other way to judge whether a point is in an  acclivitous rect? How
  to do it?
 
  Br,
  -David
  
 
 


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



[android-developers] Re: SVG files

2009-02-20 Thread Mike Reed

Sorry, we have no support for SVG in the platform.

On Fri, Feb 20, 2009 at 5:18 AM, Alam irshad...@gmail.com wrote:

 Hi,

 I've questions w.r.t svg file.
 1. Does Android support for svg files. if yes than can we use the svg
 files in our resource folder while creating applications?
 2. Is it possible to rendered svg file? What parsers are needed? Does
 android provide any such parser?

 Please let me know about this many questions.

 Thanks

 Irshad

 


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



[android-developers] Re: How to display SVG file in Android Application

2009-02-20 Thread Mike Reed

Sorry, we have no support for SVG in the platform.

On Fri, Feb 20, 2009 at 7:57 AM, Alam irshad...@gmail.com wrote:

 Hi All,

 I've some question regarding .svg file.

 1. Is it possible to display .svg file in our application as an icon
 or picture or image at background? How can we acheive it?

 2. How to render/ manipulate an .svg file on some event firing?
 3. Does Android support org.w3c.dom.svg package for parsing svg file?

 Please let me know soon your suggestion in this regard

 Thanks

 Irshad

 


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



[android-developers] Re: How to get a region which is not a standard rect area

2009-02-20 Thread Mike Reed

By bug, I mean I would like to relax the restriction, and allow you to
pass null. I don't know yet when the could get in. Thus you should
always (for now) pass in  a region as the clip. It can be something
large with no downside (i.e. -10,000,  10,000)

On Fri, Feb 20, 2009 at 3:57 PM, David Hu vistoda...@gmail.com wrote:
 Thanks for your explanation, Mike.  So, if there is not a bug,  I can pass
 the outer rect  as clip region to attain my aim, and:
 Region rgn  = new Region();
  (1)  //- actual result: The application will crash here with an
 exception here
//--expect result : ?
rgn.setPath(p, null);
   (2)  //- actual result: The region is the rect area which encircle
 the rotated
 rect, not the rotated rect itself
 //---expect result :?
 rgn.setPath(p, rgn);
   (3) //-  actual result: The region is the rect area which encircle
 the rotated
 rect, not the rotated rect itself
   //--- expect result: The region should be a complicate
 area, inclined rect clipped by the original rect
  Region clipRgn = new Region(top, bottom, left, right);
  mRgn2.setPath(p, clipRgn);
  I'll try to use outer rect region as the clip region later, see what's
 happen currently. Would you please tell me when this region bug can be
 fixed? I need try to check if my project can catch up the schedule,
 otherwise, I have to try to calculate this region by ourselves, it would
 take more efforts.

   BR,
   -David
 On Fri, Feb 20, 2009 at 10:49 PM, Mike Reed r...@google.com wrote:

 Ah, that's a bug, null should be allowed. I'll see what can be done
 there for the future.

 The clip parameter is mean to be a hint to speedup turning the path
 into a region by restricting the result to a clipped subset of the
 path. For your purposes, you can just make a big rectangular region
 for the clip. The bounds of the path or larger.

 On Thu, Feb 19, 2009 at 10:22 PM, David Hu vistoda...@gmail.com wrote:
   Thanks for your reply, Mike. I've tried your method, seems still
  not
  work yet. The second parameter of Region.setPath (clip) can't be null.
 
 
  If we use null, there will be an exception happen. So I've tried to
  use
  the region I've just constructed or the original rect region, the area
  is
  still the ourter standard rect area, not the inclined rect which rotated
  from a standard rect. Here is my code tip and possible result:
 
   //Calculate region
   top = 150;
   bottom = top + bmp.getHeight(); //bmp is a bitmap instance
   left = 200;
   right = left + bmp.getWidth();
   Path p = new Path();
   p.addRect(left, top, right, bottom, Path.Direction.CCW);
 
  // use Matrix to rotate 30 degrees
   Matrix mtx = new Matrix();
   mtx.setRotate(30);
   p.transform(mtx);
 
   Region rgn  = new Region();
   (1)  //- The application will crash here with an exception here
   rgn.setPath(p, null);
   (2)  //- The region is the rect area which encircle the rotated
  rect, not the rotated rect itself
   rgn.setPath(p, rgn);
   (3) //-  The region is the rect area which encircle the rotated
  rect, not the rotated rect itself
   Region clipRgn = new Region(top, bottom, left, right);
   mRgn2.setPath(p, clipRgn);
  BTW, I searched in android source code and www.google.com, can't find
  any
  usage of this API:
 
  public boolean setPath(Path path, Region clip)
 
  So now, my question is which clip region should I pass or any other way
  in
  order to attain my aim? Hope I've made my aim clearly.
 
  BR,
  -David
 
  On Thu, Feb 19, 2009 at 11:27 PM, Mike Reed r...@google.com wrote:
 
  You could possibly un-rotate your touch-point by 30 degrees, and then
  just use the rectangle.
 
  However, you can make complex regions by first constructing a Path,
  and then calling region.setPath(...), which converts the path into a
  region. Below is pseudo sample code:
 
  Path p = new Path();
  p.addRect(rect);// this is your rect
  p.transform(matrix); // construct a matrix and then rotate as you wish
  region.setPath(p, null);
 
  On Thu, Feb 19, 2009 at 5:01 AM,  vistoda...@gmail.com wrote:
  
 I want to judge whether the touch point(x, y) is in a region or
   not, the region is from a stardard rect by rotating specified
   degrees,
   from example, rotate 30 degrees. There is a class named Region in
   Android, but as I researched, it just supports standard rect, is
   there
   any other way to judge whether a point is in an  acclivitous rect?
   How
   to do it?
  
   Br,
   -David
   
  
  
 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com

[android-developers] Re: How to get a region which is not a standard rect area

2009-02-19 Thread Mike Reed

You could possibly un-rotate your touch-point by 30 degrees, and then
just use the rectangle.

However, you can make complex regions by first constructing a Path,
and then calling region.setPath(...), which converts the path into a
region. Below is pseudo sample code:

Path p = new Path();
p.addRect(rect);// this is your rect
p.transform(matrix); // construct a matrix and then rotate as you wish
region.setPath(p, null);

On Thu, Feb 19, 2009 at 5:01 AM,  vistoda...@gmail.com wrote:

   I want to judge whether the touch point(x, y) is in a region or
 not, the region is from a stardard rect by rotating specified degrees,
 from example, rotate 30 degrees. There is a class named Region in
 Android, but as I researched, it just supports standard rect, is there
 any other way to judge whether a point is in an  acclivitous rect? How
 to do it?

 Br,
 -David
 


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



[android-developers] Re: Drawables Galore - Optimization Question

2009-02-19 Thread Mike Reed

As part of a smart Sprite class, you may want to use
Canvas.drawBitmapRect(...), which allows you to draw a subset (rect)
of a larger bitmap. Thus a group of sprites could reference the same
shared large image, each with their own rect which pulls out the part
they want to draw.

On Wed, Feb 18, 2009 at 6:46 PM, Dianne Hackborn hack...@android.com wrote:
 The images are just stored as compressed PNGs, so the overhead for having
 theme separate is the normal PNG overhead.  Whether one way or the other
 will be a win depends on how much they compress in the two different
 configurations (which depends on the contents of the images) as well as the
 overhead per image.

 It shouldn't be too hard to implement your own SpriteDrawable if that is
 what you want.  Take a look at the BitmapDrawable code as a place to start.

 On Wed, Feb 18, 2009 at 3:30 PM, Noonien Soong nooniensoong2...@gmail.com
 wrote:

 What is the best way to store/load/handle a lot of Drawables for my
 application?

 Let me explain

 - Let's say I need to display a lot of small avatar images in my
 application
 - Lets say each avatar image has a size of 40x40 and I need to
 display 32 different sprites. Not all at the same time, but I might
 have to display 10 of them on the screen at the same time. In addition
 I need to draw them on a canvas were they walk around or something...

 My reflex would be to create one PNG with 4x8=32 tiles (size :
 320x160).
 For drawing the sprites on my canvas I would allocate a bitmap for
 each sprite, load it and then and draw it when I need to (case #1)
 However, I also need to display the avatars in other views, e.g. in a
 ListView in a different activity (case #2).

 For #2, it would be very convenient if I could have them as Drawables.
 So should I just have 32 pngs in my res/drawable directory ?

 I feel like it would be great to have something like a SpriteDrawable
 where I could specify in an xml file which part of a bigger bitmap I
 want to use as a drawable on its own.

 Or is it totally fine to have A LOT of small PNGs in my res/drawable
 folder ? Does the packaging process optimize them anyways?

 Would be great to get some input on these thoughts... Any comments
 appreciated.











 --
 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.  All such questions should be posted on public
 forums, where I and others can see and answer them.


 


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



[android-developers] Re: how to check whether a char can be or not be displayed normally?

2009-02-18 Thread Mike Reed

There is no API for that.

On Wed, Feb 18, 2009 at 11:13 AM, Paranoia zheny...@gmail.com wrote:

 basically, the default font droid can not support all of the
 characters in unicode. how can i find all unsupported characters in
 droid font?

 thanks
 


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



[android-developers] Re: WebView with Gears:

2009-02-12 Thread Mike Reed

/data/data/com.android.browser/app_plugins

On Thu, Feb 12, 2009 at 5:09 PM, Kumaravel Kandasami
kumaravel.kandas...@gmail.com wrote:
 Any idea on where the browser plugins are stored in the device?

 I looked into the data/data/com.android.browser/lib, it is empty... (used
 DDMS FileExplorer).

 Is there any tools to remote connect from MAC/Windows to Linux Android
 device... like similar to ssh and basically run an 'ls' command ... it might
 help in searching quicker.

 P.S. Plz bear with me...I am thinking out loud here ..

 Kumar_/|\_
 www.saisk.com
 ku...@saisk.com
 making a profound difference with knowledge and creativity...


 On Thu, Feb 12, 2009 at 3:28 PM, Mark Murphy mmur...@commonsware.com
 wrote:

  Being that the browser supports there should be somewhere gears plugin
  in
  the pile, and can we explicitly associate with the WebView component ?

 You're welcome to hunt around and try. I haven't looked, personally -- I'm
 merely echoing statements made by the core Android team made last year,
 when Ed Burnette reported that Gears was available in the Browser
 application.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!






 


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



[android-developers] Re: ImageView.setColorFilter and/or LightingColorFilter- how to use them?

2009-02-10 Thread Mike Reed

The int values are colors (see android.graphics.Color), and each of
its 4 bytes (one for each alpha, red, green, blue components) range
from 0..255, thus you can multiply/add each component with different
coefficients.

On Mon, Feb 9, 2009 at 5:52 PM, myIP marckas...@gmail.com wrote:

 It looks like the int values can range from -255 to 255.  I was
 mislead, the docs has a range of values of 0 to 255.

 On Feb 9, 5:06 pm, myIP marckas...@gmail.com wrote:
 How would I be able to adjust a channel (R,G or B) using
 ImageView.setColorFilter by passing an instance of LightingColorFilter
 in its construct?

 For an example, when I create an instance of LightingColorFilter, I
 adjust the two params that are int values between 0-255.  With this
 instance, I then pass it into setColorFilter.  The image always ends
 up anywhere from being black to blue.  How can I adjust the Red or
 Green channel?

 LightingColorFilter lcf = new LightingColorFilter( mul, add);
 imageView.setColorFilter(lcf);
 


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



[android-developers] Re: ImageView.setColorFilter and/or LightingColorFilter- how to use them?

2009-02-10 Thread Mike Reed

If you want to set a component (e.g. RED) to zero, use these

mul: 0xFF00
add: 0

If you want to force a component to be full-on (e.g. BLUE), use these

mul: 0x
add: 0x00FF

If you want to slightly darken RED and GREEN, use

mul: 0xFFFF
add: 0

On Tue, Feb 10, 2009 at 3:41 PM, myIP marckas...@gmail.com wrote:

 Mike, thanks for the reply.  Perhaps I don't fully understand how a
 value is assigned to a color.  Forgive me, I should have said  I am
 perplexed rather then I was mislead.

 Anyways, I am still perplexed.  Can you give an example on how to
 manipulate a red or green component?  Do I need to use
 android.graphics.Color.rgb() or Color.red(), etc., with
 LightingColorFilter?  I can't seem to get any color other then blue,
 if I don't use a neg value.

 On Feb 10, 7:47 am, Mike Reed r...@google.com wrote:
 The int values are colors (see android.graphics.Color), and each of
 its 4 bytes (one for each alpha, red, green, blue components) range
 from 0..255, thus you can multiply/add each component with different
 coefficients.

 On Mon, Feb 9, 2009 at 5:52 PM, myIP marckas...@gmail.com wrote:

  It looks like the int values can range from -255 to 255.  I was
  mislead, the docs has a range of values of 0 to 255.

  On Feb 9, 5:06 pm, myIP marckas...@gmail.com wrote:
  How would I be able to adjust a channel (R,G or B) using
  ImageView.setColorFilter by passing an instance of LightingColorFilter
  in its construct?

  For an example, when I create an instance of LightingColorFilter, I
  adjust the two params that are int values between 0-255.  With this
  instance, I then pass it into setColorFilter.  The image always ends
  up anywhere from being black to blue.  How can I adjust the Red or
  Green channel?

  LightingColorFilter lcf = new LightingColorFilter( mul, add);
  imageView.setColorFilter(lcf);
 


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



[android-developers] Re: J2ME Sprite equivalent api

2009-02-09 Thread Mike Reed

I'm not familiar with the J2ME sprite facilities. With
android.graphics.canvas/bitmap, you should be able to draw bitmaps
with any alpha, any matrix transformation, through any clip. Do you
need other facilities?

On Fri, Jan 30, 2009 at 5:25 AM, Raja Nagendra Kumar
nagendra.r...@gmail.com wrote:

 Does Android has any equivalent Sprint API of J2ME..

 Drawable does not seem to support cliping regions...

 Regards,
 Raja Nagendra Kumar.
 C.T.O
 www.tejasoft.com
 


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



[android-developers] Re: BitmapShader performance

2009-02-09 Thread Mike Reed

Performance is bug like any other, so feel free to report them as bugs.

Is your surface 32bit or 16bit? If it is 16bit, then I should
definitely have noticed the SRC mode and made that fast (i.e. memcpy).

On Sun, Feb 8, 2009 at 6:27 PM, Tom Gibara m...@tomgibara.com wrote:
 Thanks for the details.
 I did think that the disparity might be the result of a unoptimized code
 paths, but my understanding of how the Shader integrates into the rendering
 implementation as a whole was too sketchy to know whether this would be an
 optimization that one might reasonably expect to be feasible.
 In my case, the optimization isn't vital since the existing code works
 pretty much as well as I need it to - I guess the tiles are large enough
 that the overhead of rendering them separately isn't too great.
 As a general point, I've run into a few surprises regarding the performance
 characteristics of certain graphical operations. One I ran into yesterday
 was that drawing an RGB_565 image (without matrix) onto a Canvas obtained
 from a SurfaceView became significantly slower after specifying SRC mode on
 the Paint object. Given that there is no alpha channel on the src, I would
 have expected the SRC mode to have been a noop at worst, and at best trigger
 an optimization.
 I hesitate to report these as issues because knowing what the expected
 performance should be (or can be expected to be) seems very difficult.
 Tom.
 2009/2/6 Mike Reed r...@google.com

 Doh! You've stumbled across a known missing optimization. No promises,
 but this has been identified as an future optimization.

 The dirty details are that the current code has special optimizations
 for a straight drawBitmap when there is no matrix (other than
 translate). In addition, there is another optimization for SRC mode
 with 32bit bitmaps, where the blitter can literally call memcpy, since
 there is no need to inspect the src pixels for blending. Neither of
 these optimizations exist (yet) for the bitmapshader code.

 On Thu, Feb 5, 2009 at 5:41 PM, tomgibara m...@tomgibara.com wrote:
 
  Romain, Thanks for the explanation.
 
 
  On Feb 5, 10:26 pm, Romain Guy romain...@google.com wrote:
  Tom,
 
  A shader is a per-pixel operation, which lets you apply it to any
  shape, respecting alpha blending as well. As such it is not surprising
  that your first method is faster.
 
 
 
  On Thu, Feb 5, 2009 at 2:08 PM, tomgibara m...@tomgibara.com wrote:
 
   I'm experimenting with tiling a fullscreen image (480x320px ARGB
   bitmap) with a square image (160x160px ARGB bitmap). My initial
   implementation was naive:
 
   public void render(Canvas canvas) {
  final int size = tile.getWidth();
  final int w = canvas.getWidth();
  final int h = canvas.getHeight();
  for (int y = 0; y  h; y += size) {
  for (int x = 0; x  w; x += size) {
  canvas.drawBitmap(tile, x, y, null);
  }
  }
   }
 
   Then I remembered that Paint supports a Shader, so I swapped this
   implementation for something much more satisfying:
 
   public void render(Canvas canvas) {
  canvas.drawPaint(paint);
   }
 
   Where paint is initialized outside this method with:
 
   paint = new Paint();
   paint.setShader(new BitmapShader(tile, Shader.TileMode.REPEAT,
   Shader.TileMode.REPEAT));
 
   I expected that using a BitmapShader would be competitive with the
   first implementation and probably slightly faster. But initial
   benchmarking indicates that the first method is more than twice as
   fast (almost 3x as fast if PorterDuff.Mode.SRC is used for both). I
   found that surprising.
 
   Is there a good reason that the BitmapShader is necessarily much
   slower, or does it point to a deficiency in its implementation?
 
  --
  Romain Guy
  Android framework engineer
  romain...@android.com
 
  Note: please don't send private questions to me, as I don't have time
  to provide private support.  All such questions should be posted on
  public forums, where I and others can see and answer them
  
 




 


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



[android-developers] Re: Graphics question: bilinear interpolation

2009-02-09 Thread Mike Reed

You may be right. The filter_flag kicks in when drawing a bitmap
through a matrix (scale, rotate, etc.). If you are doing arbitrary
distortions in java, then I'm afraid the graphics API can't help
per-se.

On Sun, Feb 8, 2009 at 4:56 PM, j jac...@gmail.com wrote:

 Hi Dianne,

 I am afraid I don't understand how that would help.  I am implementing
 an image distortion algorithm.  It takes in a source Bitmap and output
 a distorted Bitmap.

 Can you elaborate?

 On Feb 7, 8:15 pm, Dianne Hackborn hack...@android.com wrote:
 How about this:

 http://code.google.com/android/reference/android/graphics/Paint.html#...

 On Sat, Feb 7, 2009 at 8:06 PM, j jac...@gmail.com wrote:

  Is there an Android API for performing bilinear interpolation?  I
  discovered that my own interpolation implementation is extremely slow
  running on the G1 so it's pretty useless.

 --
 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.  All such questions should be posted on public
 forums, where I and others can see and answer them.
 


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



[android-developers] Re: Read/write JPEG metadata (e.g. in EXIF format)

2009-02-09 Thread Mike Reed

Gotcha. Sounds like a reasonable request for some future release.

On Sun, Feb 8, 2009 at 2:25 AM, GiladH gila...@gmail.com wrote:

 Hi Mike,

 The standard staff - creation date and location, original rotation
 etc.

 The thing is, and correct me if you see otherwise,  that while an
 imported jpeg get added to the MediaStore,
 all this info stored in its metadata is not converted to MediaStore
 metadata, hence the need for direct jpeg acces.

 GiladH
 


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



[android-developers] Re: Color filter modes and transparent colors

2009-02-09 Thread Mike Reed

Sounds like a bug: DARKEN should not alter a fully transparent pixel.
I will try to reproduce. Does SRC_OVER + some shade of gray work for
you, like 0x)?

On Sat, Feb 7, 2009 at 2:01 AM, Obormot atru...@gmail.com wrote:

 Hi, guys.

 I'm trying to make an image darker, but the image has some pixels
 transparent. I want to keep those pixels intact. I tried DARKEN and
 couple other filters, but they seem to alter transparent pixels as
 well.

 Do you know if there is a way to keep transparent pixels intact while
 applying a color filter?

 Sincerely,
  A.
 


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



[android-developers] Re: Color filter modes and transparent colors

2009-02-09 Thread Mike Reed

Glad MULTIPLY worked for you.

I think DARKEN should have worked, assuming your op-color had zero
alpha in it (so as not to affect the resulting alpha). e.g. 0x0088

On Mon, Feb 9, 2009 at 12:09 PM, Obormot atru...@gmail.com wrote:

 I don't think there's a bug there, but maybe it wasn't the right
 filter for me.

 I tried SRC_OVER. Here's the result:
 http://tourizo.org/src_over.PNG
 2 buttons. One is with the SRC_OVER applied with the color you
 suggested.


 This worked for me much better:
iv.setColorFilter(_darkenColor, PorterDuff.Mode.MULTIPLY);
 Where _darkenColor is defined like this:
private final static int _darkenColor = Color.parseColor
 (#FF808080);

 Here's the result:
 http://tourizo.org/multiply.PNG



 On Feb 9, 8:22 am, Mike Reed r...@google.com wrote:
 Sounds like a bug: DARKEN should not alter a fully transparent pixel.
 I will try to reproduce. Does SRC_OVER + some shade of gray work for
 you, like 0x)?

 On Sat, Feb 7, 2009 at 2:01 AM,Obormotatru...@gmail.com wrote:

  Hi, guys.

  I'm trying to make an image darker, but the image has some pixels
  transparent. I want to keep those pixels intact. I tried DARKEN and
  couple other filters, but they seem to alter transparent pixels as
  well.

  Do you know if there is a way to keep transparent pixels intact while
  applying a color filter?

  Sincerely,
   A.
 


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



[android-developers] Re: Color filter modes and transparent colors

2009-02-09 Thread Mike Reed

Yea, you're right. I should think before I type.

Hurray for MULTIPLY!

On Mon, Feb 9, 2009 at 12:43 PM, Obormot atru...@gmail.com wrote:

 Just tried that as well. Doesn't affect the picture at all.
 I assume that's because of 00 alpha portion. So it's got to be more
 than 00 to alter the image.

 On Feb 9, 11:33 am, Mike Reed r...@google.com wrote:
 Glad MULTIPLY worked for you.

 I think DARKEN should have worked, assuming your op-color had zero
 alpha in it (so as not to affect the resulting alpha). e.g. 0x0088

 On Mon, Feb 9, 2009 at 12:09 PM, Obormot atru...@gmail.com wrote:

  I don't think there's a bug there, but maybe it wasn't the right
  filter for me.

  I tried SRC_OVER. Here's the result:
 http://tourizo.org/src_over.PNG
  2 buttons. One is with the SRC_OVER applied with the color you
  suggested.

  This worked for me much better:
 iv.setColorFilter(_darkenColor, PorterDuff.Mode.MULTIPLY);
  Where _darkenColor is defined like this:
 private final static int _darkenColor = Color.parseColor
  (#FF808080);

  Here's the result:
 http://tourizo.org/multiply.PNG

  On Feb 9, 8:22 am, Mike Reed r...@google.com wrote:
  Sounds like a bug: DARKEN should not alter a fully transparent pixel.
  I will try to reproduce. Does SRC_OVER + some shade of gray work for
  you, like 0x)?

  On Sat, Feb 7, 2009 at 2:01 AM,Obormotatru...@gmail.com wrote:

   Hi, guys.

   I'm trying to make an image darker, but the image has some pixels
   transparent. I want to keep those pixels intact. I tried DARKEN and
   couple other filters, but they seem to alter transparent pixels as
   well.

   Do you know if there is a way to keep transparent pixels intact while
   applying a color filter?

   Sincerely,
A.
 


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



[android-developers] Re: quick questions about Skia in android

2009-02-09 Thread Mike Reed

Start your adventure by instantiating SkGLCanvas (after you have a
current gl context) and then draw into it.

On Mon, Feb 9, 2009 at 4:31 PM, thesquib thesq...@gmail.com wrote:

 Not officially supported, but is possible? How might we go about
 using this unsupported redirection to GL canvas?


 On Jan 6, 3:43 am, Mike Reed r...@google.com wrote:
 Skia is a 2D engine for drawing to abitmap. However, there is
 experimental support for a canvas that redirects its calls to aGL
 context, but this is not officially supported at the moment.

 On Dec 31, 2008, at 3:15 AM, Andy Quan wrote:

 Anyone knows what the relationship between Skia and OpenGL is?
 Is Skia for 2D purpose only?
 Is Skia in android accelarated by OpenGL(libagl)?

 --
 Regards,
 Andy Quan
 


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



[android-developers] Re: Read/write JPEG metadata (e.g. in EXIF format)

2009-02-06 Thread Mike Reed

There is not (afaik) yet. What specific uses do you have (to help
scope the request)?

On Fri, Feb 6, 2009 at 5:43 AM, GiladH gila...@gmail.com wrote:

 Hey guys,

 Is there a way to directly access a Jpeg's file metadata, without
 having to go through the ImageManager services?


 Tnx, GiladH


 


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



[android-developers] Re: BitmapShader performance

2009-02-06 Thread Mike Reed

Doh! You've stumbled across a known missing optimization. No promises,
but this has been identified as an future optimization.

The dirty details are that the current code has special optimizations
for a straight drawBitmap when there is no matrix (other than
translate). In addition, there is another optimization for SRC mode
with 32bit bitmaps, where the blitter can literally call memcpy, since
there is no need to inspect the src pixels for blending. Neither of
these optimizations exist (yet) for the bitmapshader code.

On Thu, Feb 5, 2009 at 5:41 PM, tomgibara m...@tomgibara.com wrote:

 Romain, Thanks for the explanation.


 On Feb 5, 10:26 pm, Romain Guy romain...@google.com wrote:
 Tom,

 A shader is a per-pixel operation, which lets you apply it to any
 shape, respecting alpha blending as well. As such it is not surprising
 that your first method is faster.



 On Thu, Feb 5, 2009 at 2:08 PM, tomgibara m...@tomgibara.com wrote:

  I'm experimenting with tiling a fullscreen image (480x320px ARGB
  bitmap) with a square image (160x160px ARGB bitmap). My initial
  implementation was naive:

  public void render(Canvas canvas) {
 final int size = tile.getWidth();
 final int w = canvas.getWidth();
 final int h = canvas.getHeight();
 for (int y = 0; y  h; y += size) {
 for (int x = 0; x  w; x += size) {
 canvas.drawBitmap(tile, x, y, null);
 }
 }
  }

  Then I remembered that Paint supports a Shader, so I swapped this
  implementation for something much more satisfying:

  public void render(Canvas canvas) {
 canvas.drawPaint(paint);
  }

  Where paint is initialized outside this method with:

  paint = new Paint();
  paint.setShader(new BitmapShader(tile, Shader.TileMode.REPEAT,
  Shader.TileMode.REPEAT));

  I expected that using a BitmapShader would be competitive with the
  first implementation and probably slightly faster. But initial
  benchmarking indicates that the first method is more than twice as
  fast (almost 3x as fast if PorterDuff.Mode.SRC is used for both). I
  found that surprising.

  Is there a good reason that the BitmapShader is necessarily much
  slower, or does it point to a deficiency in its implementation?

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

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


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



[android-developers] Re: Read Image with multiple Frames - Animated Gif

2009-02-04 Thread Mike Reed

Sorry, the decoders don't expose per-frameness yet.

It may seem awkward, but you can load a Movie, and then draw each
frame into an offscreen bitmap, and then save/compress those into
separate files.

On Tue, Feb 3, 2009 at 5:23 PM, Siva Rajaraman sriram...@gmail.com wrote:

 Hello Everyone,

 I would like to know how to read in an image file which has multiple
 frames in it. Something like an animated gif file. I would like to
 perform frame by frame animation with a file of this type. I don't
 want to have each frame as drawables in the resource directory. Can
 anyone trhow some light on how to perform the above mentioned tasks.

 Thanks

 Siva

 P.S - I have already checked the example in the API demos where an
 animated gif is read as an object of type Movie. I don't want to read
 it in as a movie file.

 


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



[android-developers] Re: Does Android Browser support right menu - open with ?

2009-01-22 Thread Mike Reed

If you long-press on a link, the browser brings up a menu of options.
If that isn't sufficient, can you explain in more detail the scenario
you'd like to support? What is the link to? Is it sufficient that you
can copy the link to the clipboard?

On Thu, Jan 22, 2009 at 3:16 AM, Guolong liuguolong...@gmail.com wrote:

 Hello,

 I want to implement the following scenario:

 when user browses a web page and right-click a link, then user can
 choose to open the link with a different Application (except Browser).

 Is it possible in Android?


 


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



[android-developers] Re: size of Bitmap

2009-01-21 Thread Mike Reed

The config (size, format, etc.) of a bitmap is immutable. It can only
be specified when the bitmap is first created.

On Wed, Jan 21, 2009 at 11:05 AM, elo esyo...@gmail.com wrote:

 HI
 I would like to set the size of a Bitmap, there are no setWidth() or
 setHeight() so I don't know how to do this

 Thank you
 


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



[android-developers] Re: Round Corners of Bitmap

2009-01-20 Thread Mike Reed

You can also draw a roundrect (with antialiasing on the paint) with
that xfermode to get the same effect.

On Mon, Jan 19, 2009 at 12:49 PM, Patrick bpatm...@gmail.com wrote:

 You could have a 9-patch drawable that is an alpha mask of the shape
 you want to keep, and draw that onto the canvas obtained from the
 bitmap using the DST_IN PorterDuff mode. Making it a 9-patch will let
 you set the corners to not stretch, so you can use it no matter the
 size of the destination bitmap.

 


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



[android-developers] Re: Saving/Loading dynamic Bitmaps

2009-01-15 Thread Mike Reed

Can you call Bitmap.compress() and just stored the resulting
png-stream in your file?

On Wed, Jan 14, 2009 at 9:37 PM, Patrick bpatm...@gmail.com wrote:

 Ok, I have to post again, because what appears to have worked before
 only did if the alpha channel of the bitmap was mostly opaque.

 All I need is to save and load a bitmap inside a file of my own
 format. I don't really care what format the bitmap data itself has, as
 long as 100% of the data in the bitmap is restored on load, including
 the alpha channel. I have now spent several days trying to achieve
 what should be a very simple thing.

 Bitmap.getPixels clearly does not return the raw bitmap data, at least
 not for an  format. The color channels are modified based on the
 alpha in some way. Bitmap.copyPixelsToBuffer seems to return better
 results, but there is no equivalent Bitmap.copyPixelsFromBuffer to
 restore the bitmap on load, and using Bitmap.setPixels to restore
 gives a blueish tint.

 I thought of playing some trick where I would get the pixels, copy out
 the alpha component to my own storage, set the alpha to 0xFF
 everywhere on the bitmap, and then read the color out. But that
 doesn't seem to work either. The color channels are different, but
 still not correct. Pixels with a low alpha value are darker then what
 they should be. A pixel that was set to 20% opaque white comes back as
 20% opaque blackish.

 I am really at a loss as to what I can possibly do to properly extract
 and restore the exact state of a bitmap.

 


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



[android-developers] Re: Converting Bitmap to Byte Array

2009-01-12 Thread Mike Reed

Bitmap.compress(...) ?

On Sat, Jan 10, 2009 at 2:40 AM, Timothy DeWees whtdrgn...@gmail.com wrote:

 Hello,

 I need to re-size a Bitmap and save it to a database.  I can perform
 the resize, but how do I convert the re-sized Bitmap back to a Byte
 array for storage in the BLOB?

 Original format is JPG/PNG
 


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



[android-developers] Re: Help How to lazy load images

2009-01-07 Thread Mike Reed

We don't support async image decoding yet (ala push model).

On Tue, Jan 6, 2009 at 11:50 PM, jbpring...@gmail.com
jbpring...@gmail.com wrote:

 Hi

 I am using the following code to display an image from the internet

  ImageView i = new ImageView(mContext);
  i.setImageDrawable(getDrawable(http://www.google.com/images/
 nav_logo3.png));
 ...

public Drawable getDrawable(String imgUrl) {
try {
URL url = new URL(imgUrl);
InputStream is = (InputStream) url.getContent();
Drawable d = Drawable.createFromStream(is, src);
return d;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

 but I would like to be able to load the image asynchronously so that
 if I want to display a list of 10 images then the text would start to
 render and then images would load one after the other (like a
 browser...) . The problem with every code that I have seen so far is
 that it is all synchronous that is not really good for user
 experience. I am sure I am missing somthing and would really
 appreciate your help

 thanks

 jb

 


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



[android-developers] Re: Skia Graphics Library

2009-01-07 Thread Mike Reed

Agreed. Skia is not offered as a lib/sharedlib inside android, as its
api is not guaranteed to be stable over time. See
code.google.com/p/skia for the active trunk.

On Wed, Jan 7, 2009 at 8:31 AM, David Turner di...@android.com wrote:
 forget about using Skia headers for deployed projects. they are not part of
 the stable Android API and *will* change in future releases, breaking your
 code in unexpected ways.

 but if you want to go that route and inflict huge pain to yourself in the
 future, have a look to android/external/skia

 On Wed, Jan 7, 2009 at 2:04 PM, sunitna...@gmail.com sunitna...@gmail.com
 wrote:

 Can anybody help me with using the Skia Graphis Library for
 implementation of various controls or even if someone can help me find
 the .h files related to SKIA in myandroid/

 It's a bit urgent...

 Regards,
 Sunit



 


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



[android-developers] Re: How to create a bitmap with desired text?

2009-01-06 Thread Mike Reed

This may not be the issue, but inside a drawable, you need to draw
everything relative to your bounds (i.e. getBounds()).

arg0.drawBitmap(getBitmap(), bounds.left, bounds.top, ...)


On Tue, Jan 6, 2009 at 3:21 AM, Ernest sunkil...@gmail.com wrote:

 Hi,Everythone
I want to create a new bitmap and use it only in memory.The bitmap
 is created from an exist drawable resource and paint some text in it.I
 tested the BitmapDrawable,and override the draw(Canvas arg0),such as
   public void draw(Canvas arg0) {
// TODO Auto-generated method stub
Paint textPaint = new Paint();
arg0.drawBitmap(getBitmap(), 0, 0, textPaint);

textPaint.setTextSize(12);
textPaint.setTypeface(Typeface.DEFAULT);
textPaint.setAntiAlias(true);
textPaint.setStyle(Style.FILL);
arg0.drawText(name,10,10, textPaint);


}  but the bitmap is not works well,the text is not be painted.Anyone
 could help me?Thank you very much.

 Best Regards
 


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



[android-developers] Re: what's the equivalent class of java.awt.Image

2009-01-06 Thread Mike Reed

Bitmap is correct.

I also think android has awt classes implemented, btw.

On Tue, Jan 6, 2009 at 6:54 AM, Derek xianguan...@gmail.com wrote:

 I'm trying to re-implement the missing pieces of AWT the app actually
 uses.
 


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



[android-developers] Re: Working with JPEG images

2009-01-05 Thread Mike Reed

BitmapFactory.decodeStream(...)

On Sun, Jan 4, 2009 at 11:55 AM, nickthecook nickthec...@gmail.com wrote:

 Hello all,

 I'm looking for a way to work with JPEG images read from a file in
 Android. Specifically, I would like to scale them, and be able to get
 their height and width.

 I can get an InputStream to a JPEG file on the SD card, and I can work
 with the raw bytes, but I'd like something a little more high-level.

 Bitmap seems to be able to encode JPEGs, but not decode them.

 Thanks!

 


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



[android-developers] Re: Error in native method Picture.nativeCreateFromStream()

2009-01-05 Thread Mike Reed

That method should not crash (I will fix that), but it is only
intended to re-create a picture that was previously written to a
stream. It does not know how to decode or interpreted images or other
data formats. Use BitmapFactory for that.

On Sun, Jan 4, 2009 at 11:29 AM, nickthecook nickthec...@gmail.com wrote:

 Hello all,

 I'm having some trouble creating a Picture from an InputStream. I am
 trying to do this:

ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
Picture pic = Picture.createFromStream(bis);

 The problem also occurs when I try to use an InputStream returned by
 ContentResolver.openInputStream(Uri):

InputStream is = getContentResolver.openInputStream(mUri);
Picture pic = Picture.createFromStream(is);

 Picture.createFromStream(InputStream) invokes the native method
 Picture.nativeCreateFromStream(InputStream, byte[]), and this is where
 the trail goes cold for me:

public static Picture createFromStream(InputStream stream) {
return new Picture(
nativeCreateFromStream(stream, new byte
 [WORKING_STREAM_STORAGE]));
}

 I have been loading images from this Uri (content://media/external/
 images/media/152) successfully for a while. I open an InputStream,
 read all the bytes, close the input stream, and there is no problem.
 However, when I try to use either the InputStream returned by
 ContentResolver.openInputStream(Uri), or I read all the bytes out of
 that and wrap them in a ByteArrayInputStream, Picture.createFromStream
 (InputStream) fails with the stack trace below.

 Has anyone successfully used Picture.createFromStream(InputStream)?

 === Stack Trace 
 I/dalvikvm-heap( 4776): Grow heap (frag case) to 5.940MB for 316-
 byte allocation
 D/dalvikvm( 4776): GC freed 371 objects / 20736 bytes in 89ms
 I/Image   ( 4776): Read 345682 bytes for 
 content://media/external/images/media/152.
 I/DEBUG   (   29): *** *** *** *** *** *** *** *** *** *** *** *** ***
 *** *** ***
 I/DEBUG   (   29): Build fingerprint: 'android-devphone1/
 dream_devphone/dream/trout:1.0/UNLOCKED/116222:userdebug/test-keys'
 I/DEBUG   (   29): pid: 4776, tid: 4776   org.hopto.group18.postbot
 
 I/DEBUG   (   29): signal 6 (SIGABRT), fault addr 12a8
 I/DEBUG   (   29):  r0   r1 0006  r2   r3 0080
 I/DEBUG   (   29):  r4 2eb0  r5 40008000  r6   r7 0025
 I/DEBUG   (   29):  r8 beb0a630  r9 4104d9c8  10 4104d9b8  fp 
 I/DEBUG   (   29):  ip   sp beb0a5c8  lr afe0ef37  pc
 afe0d1fc  cpsr 0010
 I/DEBUG   (   29):  #00  pc afe0d1fc  /system/lib/libc.so
 I/DEBUG   (   29):  #01  pc afe0ef34  /system/lib/libc.so
 I/DEBUG   (   29):  #02  pc ace08540  /system/lib/libcorecg.so
 I/DEBUG   (   29):  #03  pc ac075cec  /system/lib/libsgl.so
 I/DEBUG   (   29):  #04  pc ad3413da  /system/lib/
 libandroid_runtime.so
 I/DEBUG   (   29):  #05  pc ad00d9f4  /system/lib/libdvm.so
 I/DEBUG   (   29):  #06  pc ad04120e  /system/lib/libdvm.so
 I/DEBUG   (   29):  #07  pc ad012748  /system/lib/libdvm.so
 I/DEBUG   (   29):  #08  pc ad02a92c  /system/lib/libdvm.so
 I/DEBUG   (   29):  #09  pc ad0169d0  /system/lib/libdvm.so
 I/DEBUG   (   29):  #10  pc ad052096  /system/lib/libdvm.so
 I/DEBUG   (   29):  #11  pc ad03ccbc  /system/lib/libdvm.so
 I/DEBUG   (   29):  #12  pc ad012748  /system/lib/libdvm.so
 I/DEBUG   (   29):  #13  pc ad02a92c  /system/lib/libdvm.so
 I/DEBUG   (   29):  #14  pc ad0169d0  /system/lib/libdvm.so
 I/DEBUG   (   29):  #15  pc ad051f10  /system/lib/libdvm.so
 I/DEBUG   (   29):  #16  pc ad03f87a  /system/lib/libdvm.so
 I/DEBUG   (   29):  #17  pc ad3282b4  /system/lib/
 libandroid_runtime.so
 I/DEBUG   (   29):  #18  pc ad328d40  /system/lib/
 libandroid_runtime.so
 I/DEBUG   (   29):  #19  pc 8c12  /system/bin/app_process
 I/DEBUG   (   29):  #20  pc afe1dbd2  /system/lib/libc.so
 I/DEBUG   (   29):  #21  pc afe0b010  /system/lib/libc.so
 I/DEBUG   (   29):  #22  pc bd70  /system/bin/linker
 I/DEBUG   (   29): stack:
 I/DEBUG   (   29): beb0a588  beb0a630  [stack]
 I/DEBUG   (   29): beb0a58c  afe35f3c
 I/DEBUG   (   29): beb0a590  0084
 I/DEBUG   (   29): beb0a594  0001
 I/DEBUG   (   29): beb0a598  afe35f3c
 I/DEBUG   (   29): beb0a59c  000c
 I/DEBUG   (   29): beb0a5a0  afe35f3c
 I/DEBUG   (   29): beb0a5a4  afe12dbd  /system/lib/libc.so
 I/DEBUG   (   29): beb0a5a8  afe35f3c
 I/DEBUG   (   29): beb0a5ac  afe35f90
 I/DEBUG   (   29): beb0a5b0  
 I/DEBUG   (   29): beb0a5b4  afe1238d  /system/lib/libc.so
 I/DEBUG   (   29): beb0a5b8  ace0acc0  /system/lib/libcorecg.so
 I/DEBUG   (   29): beb0a5bc  afe11539  /system/lib/libc.so
 I/DEBUG   (   29): beb0a5c0  df002777
 I/DEBUG   (   29): beb0a5c4  

[android-developers] Re: Problem saving canvas to file

2009-01-05 Thread Mike Reed

Your code does not change bitmapOrg, but does create a new bitmap  
(whatever bitmap the canvas is drawing into). I expect you want to  
compress *that* bitmap to a file.

begin pseudo code

b = Bitmap.createBitmap(...);
c = new Canvas(b);
// now draw into c, e.g. c.drawBitmap(...), etc.
b.compress(...);

On Jan 4, 2009, at 8:26 AM, Protocol-X wrote:


Ive been searching all ove on how to edit a image and save it. The
only way i have come accross other than just changing the size or
orientation is to use canvas.  Now canvas works fine but i cannot seem
to save the newley created image.. the image always returns the
original image.


   @Override protected void onDraw(Canvas canvas) {

FileInputStream in = null;
try {
in = new FileInputStream(myimage.jpg);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Bitmap bitmapOrg = BitmapFactory.decodeStream(in);

int wd = bitmapOrg.getWidth();
int hd = bitmapOrg.getHeight();

canvas.drawBitmap(bitmapOrg, 0, 0, null);
canvas.drawBitmap(bitmapOrg, wd, 0, null);
canvas.drawBitmap(bitmapOrg, 0, hd, null);
canvas.drawBitmap(bitmapOrg, wd, hd, null);

canvas.save();

  FileOutputStream fos = null;
  try {
fos = new FileOutputStream(/sdcard/test.png);
} catch (FileNotFoundException e) {

e.printStackTrace();
}
bitmapOrg.compress(Bitmap.CompressFormat.PNG, 50, fos);

 try {
fos.close();
} catch (IOException e) {

e.printStackTrace();
}
}




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



[android-developers] Re: quick questions about Skia in android

2009-01-05 Thread Mike Reed

Skia is a 2D engine for drawing to a bitmap. However, there is  
experimental support for a canvas that redirects its calls to a GL  
context, but this is not officially supported at the moment.

On Dec 31, 2008, at 3:15 AM, Andy Quan wrote:

Anyone knows what the relationship between Skia and OpenGL is?
Is Skia for 2D purpose only?
Is Skia in android accelarated by OpenGL(libagl)?

-- 
Regards,
Andy Quan




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



[android-developers] Re: Freeing Bitmaps

2008-12-23 Thread Mike Reed
That looks fine. The only issue/trick for bitmaps that I'm aware of is  
the option to call bitmap.recycle(), which forces the bitmap to free  
its pixel memory immediately, rather than waiting for the GC. This is  
optional, since the GC will trigger this too. Calling recycle() is  
tricky, because now the bitmap object is dead, and will throw an  
exception if it is used, so only do this if you're low on memory, and  
want to free some up right away (and you're SURE you won't reference  
that bitmap again).

On Dec 23, 2008, at 1:08 PM, Brad Gies wrote:


I’ve seen many discussions on freeing Bitmaps, but I don’t think I  
have ever seen a definitive answer on the proper method of doing it.

I have an activity which creates a custom class, and the custom class  
has a clear method, which I call before freeing the class.

Below is the code from my custom class, and, and following it is the  
code from the OnDestroy event . Is this sufficient to make sure I am  
not leaking memory? Note that it is untested code right now, so may  
contain a few spelling mistakes.


public class JSONDataTable
{
 public ArrayListBitmap BitmapArray;

…..
 Methods etc.
   ……

public void Clear()
 {
   if (BitmapArray != null)
   {
   for (int i = BitmapArray.size() - 1; i  -1 ; i-- )
   {
 BitmapArray.set(i, null);
 BitmapArray.remove(i);
   }
   }
   BitmapArray = null;
  }

}


FROM THE ACTIVITY

 protected void onDestroy()
 {
 if (JSONProductTable != null) {
   JSONProductTable.Clear();
   JSONProductTable = null;
  }
 }







Sincerely,

Brad Gies


-
Brad Gies
27415 Greenfield Rd, # 2,
Southfield, MI, USA
48076
-

Moderation in everything, including abstinence





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



[android-developers] Re: OutOfMemoryError BitmapFactory.nativeDecodeByteArray inside Threads

2008-12-17 Thread Mike Reed

Its a little raw, but if you know you're absolutely done using a given  
bitmap object, you can call bitmap.recycle(). This immediately frees  
up the memory associated with the bitmap, and marks it as dead,  
meaning it cannot be referenced again (i.e. don't try to draw or get/ 
set its pixels anymore).

i.e.

for (all of my big images) {
 Bitmap b = decode(...);
 canvas.drawBitmap(b, ...);
 b.recycle();
 // yikes, don't reference b again)
}

On Dec 15, 2008, at 9:04 PM, Mark K wrote:



  Is there a work around for this problem? Something I need to do
differently perhaps? It seems like garbage collection is not occurring
between successive bitmap decoding operations. Explicitly calling gc()
does not seem to help. This is particularly a problem on the G1,
because there is no way to reduce the camera resolution, all of the
camera pictures are large. If I loop through a directory of pictures
taken by the camera and use BitmapFactory.decodeFile(), I will get an
out of memory error on the 2nd or 3rd iteration. Since I am only
displaying/decoding one bitmap at a time I would hope that garbage
collection would free up the memory between operations such that this
does not occur. Any help would be greatly appreciated. Here's the code
I use: This code runs a slide show of the images in the camera
directory, it uses Handler.postDelayed() to render each picture. Is
there anyway to tweak the code to get rid of the out of memory
problem.

public boolean slideShow()
{
String baseDir = /sdcard/dcim/Camera/;
long showTime = 1500;

File dir = new File(baseDir);
File[] pics = dir.listFiles();
for ( int i=0; ipics.length; i++ )
{
String pic=baseDir+pics[i].getName();
handler.postDelayed(new ShowSlide(pic), i*showTime);
}
return true;
}

class ShowSlide extends Thread
{
String pc=;
public ShowSlide(String pc)
{
this.pc=pc;
}
public void run()
{
System.out.println(Showing picture: +pc.toString());
displayPicture(pc);
}
}

public boolean displayPicture(String filepath)
{
   File file = new File(filepath);
BitmapFactory bfac = new BitmapFactory();
try
{
bm = bfac.decodeFile(filepath);// out of memory error occurs
here!
handler.post(new SetImage(iView, bm));
}
catch(Exception e)
{
   Log.e(TAG,display picture failed: +filepath+ +e.toString
());
   e.printStackTrace();
   return false;
}

return true;
}

class SetImage extends Thread
{
ImageView vv;
Bitmap bb;
public SetImage(ImageView vv, Bitmap bb)
{
this.vv=vv;
this.bb=bb;
}
public void run()
{
vv.setImageBitmap(bb);
}
}



On Dec 15, 2:48 pm, Romain Guy romain...@google.com wrote:
  I've run into this exact same problem a number of times myself. Not
 sure if its a bug or just a limitation of the jvm, can't seem to
 process more than a few large bitmaps without this occuring, this
 always seems to occur when decoding bitmaps from file.

 Neither, you are just using too much memory.

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

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



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



[android-developers] Re: OutOfMemoryError BitmapFactory.nativeDecodeByteArray inside Threads

2008-12-15 Thread Mike Reed

Depending on the details, bitmap pixels may be allocated in the VM  
heap or in the native heap, but in the latter case, we still debit the  
VM's heap by the amount that was allocated, so that in either case we  
don't exceed the per-app budget. This may explain why you're running  
out of heap even though DDMS doesn't see the allocations.


On Dec 15, 2008, at 2:29 PM, Mark K wrote:



  I've run into this exact same problem a number of times myself. Not
sure if its a bug or just a limitation of the jvm, can't seem to
process more than a few large bitmaps without this occuring, this
always seems to occur when decoding bitmaps from file. Hopefully its
on the radar as a bug and will get fixed at some point. This is a
problem since de-coding bitmaps from file is a fairly common
operation.

  Mark

On Dec 14, 9:49 am, plusminus stoeps...@gmx.de wrote:
 The following situation happens only in a few cases, but it does more
 than once.
 -

 I'm receiving several OutOfMemoryError in
 BitmapFactory.nativeDecodeByteArray.

 DDMS-Heap-View never broke the 16MB barrier. I can't even get it above
 6MB, while going wild and smashing keys like a monkey:
 ---
 1   5,820 MB2,751 MB3,069 MB47,26%  54.433
 ---

 The situation is that I have a ThreadPoolExector:
 ---
 protected ExecutorService mThreadPool = Executors.newCachedThreadPool
 ();
 ---
 ... ,which load several 256x256 pngs to the RAM. (Average png-size: 
 20kb)

 StackTrace-Desciption:
 That OutOfMemoryError happens several times in the Threads, until the
 VM decides its enough and stops the whole process.

 StackTrace:
 #
 W/AudioFlinger(   24): write blocked for 49 msecs
 W/AudioFlinger(   24): write blocked for 48 msecs
 W/AudioFlinger(   24): write blocked for 49 msecs
 D/dalvikvm(  410): GC freed 31478 objects / 1613104 bytes in 196ms
 D/dalvikvm(  410): GC freed 6404 objects / 991024 bytes in 151ms
 D/dalvikvm(  410): GC freed 5224 objects / 1229888 bytes in 137ms
 E/SOCKETLOG(  410): add_recv_stats recv 0
 E/SOCKETLOG(  410): add_recv_stats recv 0
 E/SOCKETLOG(  410): add_recv_stats recv 0
 E/SOCKETLOG(  410): add_recv_stats recv 0
 E/dalvikvm-heap(  410): 65536-byte external allocation too large for
 this process.
 E/dalvikvm-heap(  410): 65536-byte external allocation too large for
 this process.
 E/(  410): VM won't let us allocate 65536 bytes
 W/dalvikvm(  410): threadid=59: thread exiting with uncaught exception
 (group=0x40010e28)
 E/AndroidRuntime(  410): Uncaught handler: thread pool-8-thread-6
 exiting due to uncaught exception
 E/(  410): VM won't let us allocate 65536 bytes
 E/dalvikvm-heap(  410): 65536-byte external allocation too large for
 this process.
 W/dalvikvm(  410): threadid=65: thread exiting with uncaught exception
 (group=0x40010e28)
 E/dalvikvm-heap(  410): 65536-byte external allocation too large for
 this process.
 E/(  410): VM won't let us allocate 65536 bytes
 W/dalvikvm(  410): threadid=43: thread exiting with uncaught exception
 (group=0x40010e28)
 E/AndroidRuntime(  410): Uncaught handler: thread pool-8-thread-3
 exiting due to uncaught exception
 E/AndroidRuntime(  410): java.lang.OutOfMemoryError: bitmap size
 exceeds VM budget
 E/AndroidRuntime(  410):at
 android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
 E/AndroidRuntime(  410):at
 android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:234)
 E/AndroidRuntime(  410):at
 android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:247)
 E/AndroidRuntime(  410):at
 org.andnav2.osm.views.tiles.OSMMapTileFilesystemCache$1.run
 (OSMMapTileFilesystemCache.java:234)
 E/AndroidRuntime(  410):at
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask
 (ThreadPoolExecutor.java:648)
 E/AndroidRuntime(  410):at
 java.util.concurrent.ThreadPoolExecutor$Worker.run
 (ThreadPoolExecutor.java:673)
 E/AndroidRuntime(  410):at java.lang.Thread.run(Thread.java:
 935)
 E/(  410): VM won't let us allocate 65536 bytes
 E/AndroidRuntime(  410): Uncaught handler: thread pool-8-thread-9
 exiting due to uncaught exception
 E/dalvikvm-heap(  410): 65536-byte external allocation too large for
 this process.
 E/(  410): VM won't let us allocate 65536 bytes
 W/dalvikvm(  410): threadid=61: thread exiting with uncaught exception
 (group=0x40010e28)
 E/AndroidRuntime(  410): java.lang.OutOfMemoryError: bitmap size
 exceeds VM budget
 E/AndroidRuntime(  410):at
 android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
 E/AndroidRuntime(  410):at
 android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:234)
 E/AndroidRuntime(  410):at
 

[android-developers] Re: How to add new font to android browse ?

2008-12-15 Thread Mike Reed

Applications can add new fonts, but they are only visible within that  
application. The ability to add system-wide fonts is not supported at  
this time.

On Dec 14, 2008, at 8:43 AM, Milad wrote:


I can not see persian font's in my G1 browser,
Is any way to add new set of font's to G1 ?




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



[android-developers] Re: Canvas.drawBitmap(int[] colors, ...) creates wrong alpha blending

2008-12-11 Thread Mike Reed

Sounds like a good bug. Can you file it as one, and I'll take a look?

On Dec 10, 2008, at 2:31 PM, Toothy Bunny wrote:


I could not find a way to attach pictures with my post, so I post the
screen shot on the web, and here is the link:

The test screen shot:
http://www.omnigsoft.com/TechnicalSupport/TestResult.png

The original PNG image (with alpha channel) I used for the test:
http://www.omnigsoft.com/TechnicalSupport/pngWithAlpha.png

Hongkun
OmniGSoft




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Using Homemade TrueType Fonts In Android

2008-12-11 Thread Mike Reed

If you substitute your font for the one in ApiDemos, and rebuild them,  
do you see yours appear in ApiDemos/src/com/example/android/apis/ 
graphics/Typefaces.java?

On Dec 11, 2008, at 3:58 PM, illiniwatcher wrote:


To all:

I've noticed that Android lets developers include their own TrueType
fonts, by way of the assets\fonts folder.  This is a great feature,
and works well.

But I notice that if I copy one of my own homemade TrueType fonts -
created using CorelDraw's export function - any text I render in that
font comes out as the Android system default font rather than in the
font I've just included.

Is there something the Android environment looks for in TrueType or
*.TTF files - a digital signature, a certain character, something -
that would cause a homemade font file's outlines to be ignored?

The TTF files I've created only have a subset of the entire character
set, usually consisting only of numbers and symbols.  The TTF file
works just fine in major applications like Microsoft Office (even the
latest one) and Adobe Photoshop.  Can any of the Android developers
comment?

Thanks,
Charles





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



[android-developers] Re: the fastest way to draw on screen

2008-12-10 Thread Mike Reed

If the image is predrawn, then you can just store it as .png, and then  
decode it (BitmapFactory) with a preferred config as RGB_565 (see  
BitmapFactory options).

If the image is drawn by your code, and you can create a Bitmap in  
RGB_565, and use setPixels(int[]), which will down-sample your ints to  
565 shorts for you.

Either way, the resulting Bitmap will be 565, which should draw very  
quickly to the screen (assuming no matrix on the canvas, and no alpha  
or colorFilter or xfermode on the paint).

On Dec 10, 2008, at 5:39 AM, Romkin wrote:


To be honest the surface in created in C, as char* and originally i
wanted to use 16bit colour, but Bitmap takes int[], which means i have
to use 32bit, is there a way i can solve it to use 16bit?

On 9 Dec, 17:38, Mike Reed [EMAIL PROTECTED] wrote:
 I am assuming you have predrawn what you want in the Bitmap. If so, be
 sure that the Bitmap's config matches your window (typically 565),
 otherwise things will go a lot slower, as we depth-convert your Bitmap
 each time it is drawn.

 If you have a large area that is a solid color, it might be faster to
 draw that (via canvas.drawColor or canvas.drawRect) and then draw the
 bitmap. It all depends, but the fastest a Bitmap can go is memcpy, but
 drawing a large area in a solid color can use memset, which is faster
 for the same number of dst pixels.

 On Dec 9, 2008, at 11:54 AM, Romkin wrote:

 What is the fastest way to draw on screen?

 currently we use OnDraw and have Bitmap, but is there a faster way to
 draw pixel array to screen?

 Thanks.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: the fastest way to draw on screen

2008-12-09 Thread Mike Reed

I am assuming you have predrawn what you want in the Bitmap. If so, be  
sure that the Bitmap's config matches your window (typically 565),  
otherwise things will go a lot slower, as we depth-convert your Bitmap  
each time it is drawn.

If you have a large area that is a solid color, it might be faster to  
draw that (via canvas.drawColor or canvas.drawRect) and then draw the  
bitmap. It all depends, but the fastest a Bitmap can go is memcpy, but  
drawing a large area in a solid color can use memset, which is faster  
for the same number of dst pixels.

On Dec 9, 2008, at 11:54 AM, Romkin wrote:


What is the fastest way to draw on screen?

currently we use OnDraw and have Bitmap, but is there a faster way to
draw pixel array to screen?

Thanks.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: How to create bitmap directly from byte array?

2008-12-09 Thread Mike Reed

Sorry, there is no API for creating bitmaps from anything but int[] at  
the moment.

For future reference, how should the system interpret the bytes you  
want to send it? Are the indices into a colortable? 332 packed?

mike

On Dec 9, 2008, at 2:51 AM, shuoshuo wrote:


Hi,
   Anyone' help is appreciated.
   I now want to create bitmap using a byte array which contains the
pixels data, one byte correspond one pixel.
   But I found that the no api of bitmap accept bytearray, only int
[] , 4 bytes correspond one pixel. If I convert my bytearray to int[],
it will cost too much memory.
   Do anyone know how to display the image using my bytearray
directly? Thanks a lot !




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Bitmap.getPixels()

2008-12-05 Thread Mike Reed

The color seems fine. Can you enclose a code-snippet, for the draw and
the getPixels() call?

thanks

On Thu, Dec 4, 2008 at 5:55 PM, jman [EMAIL PROTECTED] wrote:

 It's 50% transparent, i.e. alpha channel is 0x80, paint color is
 0x8000ff00


 On Dec 4, 8:52 am, Robert Green [EMAIL PROTECTED] wrote:
 Did you mean partially transparent green or fully transparent?

 On Dec 4, 1:21 am, jman [EMAIL PROTECTED] wrote:

  I painted a transparent green curve on top of a background bitmap.
  When I use Bitmap.getPixels() to get the result into byte array, I
  always get a black curve.  The curve position is correct but color
  isn't.  Is there anything I need to do before calling Bitmap.getPixels
  ()?

  Thanks.
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Top Status Bar Webkit transparent

2008-12-05 Thread Mike Reed

We do no t have that feature yet.

On Dec 5, 2008, at 6:35 AM, Fred Grott(shareme) wrote:


I have a question

in iPhone you can make the top bar go away in the wbekit view see:

http://ajaxian.com/archives/iphone-full-screen-webapps

If the same feature is in Android webkit what meta tag valeus would I
use to enable it?

I assume that it may be android_something-something or etc.

Thanks..because I know how long you will search to find this answer



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: java.awt.polygon equivalent in android?

2008-12-03 Thread Mike Reed

If you're looking for polygons, try either android.graphics.Path, or  
android.graphics.Canvas.drawPoints(...)

On Dec 3, 2008, at 4:31 PM, chas__123 wrote:


Hi,

I'm trying to draw an n-dimensional polygon and unable to find an
equivant api to awt.polynomial. Does anyone know if there is one?

rgds, C




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Loading a bitmap from a byte buffer

2008-12-02 Thread Mike Reed

The only ways to specify the pixels directly are via:
- consing up a BMP in memory
- using setPixels(...) api (which takes 32bit ARGB ints)

I apologize there there is no direct API that takes 565 values as input.

On Dec 2, 2008, at 4:41 AM, Koush wrote:


{ SkImageDecoder_GIF_Factory,   SkImageDecoder::kGIF_Format },
{ SkImageDecoder_PNG_Factory,   SkImageDecoder::kPNG_Format },
{ SkImageDecoder_ICO_Factory,   SkImageDecoder::kICO_Format },
{ SkImageDecoder_WBMP_Factory,  SkImageDecoder::kWBMP_Format },
{ SkImageDecoder_BMP_Factory,   SkImageDecoder::kBMP_Format },
// jpeg must be last, as it doesn't have a good sniffer yet
{ SkImageDecoder_JPEG_Factory,  SkImageDecoder::kJPEG_Format }

That's the list of formats supported by SKImageDecoder. Another
possible solution is to dummy up a BMP header (pretty trivial) and
then decode the bytes. But that is still a hack...

On Dec 2, 1:15 am, Christine [EMAIL PROTECTED] wrote:
 As John says, why don't you use BitmapFactory.decodeByteArray?

 On Dec 2, 10:03 am, Koush [EMAIL PROTECTED] wrote:

 Also, the Bitmap class internally (in the C++ JNI atleast) supports
 the all familiar lockPixels and unlockPixels methods, which allows
 direct access to the byte buffer. I would suggest extending the Java
 API to include those methods.

 On Dec 2, 1:00 am, Koush [EMAIL PROTECTED] wrote:

 Dianne Hackborn: I am asking this in the context of how to create a
 screenshot application. Taking screenshots is not possible on the G1
 anyways, because reading from /dev/graphics/fb0 is only available to
 root and shell and not available to actual applications. Thus is  
 only
 works on hacked phones. So you're asking me to not do something,  
 when
 I'm well past the line of things I should not be doing. :)
 Incidentally, the inability to take a simple screenshot of what is  
 on
 your phone is a pretty significant oversight (you're not going to
 always be hooked up to a PC with the SDK/DDMS tool at your  
 disposal).

 John Spurlock: Decode byte array is for compressed byte arrays, such
 as PNGs and JPG.
 I am basically trying to copy directly into the pixel buffer.

 On Dec 1, 3:34 pm, John Spurlock [EMAIL PROTECTED] wrote:

 BitmapFactory.decodeByteArray ?

 http://code.google.com/android/reference/android/graphics/BitmapFacto 
 ...

 On Dec 1, 5:58 pm, Koush [EMAIL PROTECTED] wrote:

 I inspected Bitmap.cpp and found this function:

 static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
  const SkBitmap* bitmap,
  jboolean isMutable, jobject
 parcel) {
 if (parcel == NULL) {
 SkDebugf(--- writeToParcel null parcel\n);
 return false;
 }

 android::Parcel* p = android::parcelForJavaObject(env,  
 parcel);

 p-writeInt32(isMutable);
 p-writeInt32(bitmap-config());
 p-writeInt32(bitmap-width());
 p-writeInt32(bitmap-height());
 p-writeInt32(bitmap-rowBytes());

 if (bitmap-getConfig() == SkBitmap::kIndex8_Config) {
 SkColorTable* ctable = bitmap-getColorTable();
 if (ctable != NULL) {
 int count = ctable-count();
 p-writeInt32(count);
 memcpy(p-writeInplace(count * sizeof(SkPMColor)),
ctable-lockColors(), count *  
 sizeof(SkPMColor));
 ctable-unlockColors(false);
 } else {
 p-writeInt32(0);   // indicate no ctable
 }
 }

 size_t size = bitmap-getSize();
 bitmap-lockPixels();
 memcpy(p-writeInplace(size), bitmap-getPixels(), size);
 bitmap-unlockPixels();
 return true;

 }

 I can manually marshal a Bitmap parcel in the proper format, and  
 then
 append the custom byte buffer, and then use createFromParcel to  
 create
 a bitmap. That gets me indirect access to creating a bitmap  
 directly
 from a byte buffer. It's a bit of a hack obviously, and not  
 ideal. Is
 there a better way to do this?

 On Dec 1, 2:41 pm, Koush [EMAIL PROTECTED] wrote:

 I'm trying to populate a create a bitmap from something other  
 than an
 RGBA int array.
 However, the Bitmap creation overloads only take int arrays as  
 inputs.

 In particular, I have a byte buffer that is in the R5G6B5  
 format that
 I want to load directly into a bitmap. The format is supposedly
 supported internally, but I can't figure out how to create the  
 bitmap
 without doing the R5G6B5 to A8R8G8B8 conversion first.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: android.graphics, drawing paths, and patterns

2008-12-02 Thread Mike Reed

Since you want to draw a bitmap, rather than a path/shape, along the  
path, I think you'll have to walk the path using PathMeasure manually.  
Something like this might be the right skeleton.

void drawBitmapAlongPath(Path p, Bitmap b) {
 Matrix m = new Matrix();
 PathMeasure meas = new PathMeasure(p, false);
 final float length = meas.getLength();
 final float advance = b.getWidth();// might be larger to have  
space between each bitmap
 float distance = 0;
 final int flags = PathMeasure.POSITION_MATRIX_FLAG |  
PathMeasure.TANGENT_MATRIX_FLAG;

 while (distance  length) {
 meas.getMatrix(distance, m, flags);
 canvas.drawBitmap(b, m, ...);
 distance += advance;
 }
}

The idea is to walk the path (via pathmeasure), and at some interval  
(measured in arc-length), retrieve the matrix for that location/angle,  
and use that to draw a bitmap. You may need to adjust the matrix (via  
preTranslate) to center the bitmap at each location.

mike

PS - the above is just a sketch. I didn't try to compile/run it.

On Dec 2, 2008, at 11:38 AM, Bradley Kite wrote:


Hi fellow developers,

I have a requirement to draw a path on a canvas (which is easy
enough), but to then stamp symbols over it every few pixels.

In particular, the symbols I want to stamp over it are .png images,
and basically change the line so that it contains 'x' shapes on it -
as an example - but the shape can be any thing that can be loaded from
a .png image. This could produce a line that looks like:

--x--x--x--x--x-- etc. - but with the 'x' shapes rotated according to
the angle of the line.

Is there any particular way that this can be done? I've gone through
the following classes - Paint, Path, PathEffect, Canvas and Bitmap -
but cannot find any way to implement the above.

The closest thing I've seen is the DashPathEffect - but all this can
do is break up the line so that dashes are included.

My feeling at this point is that I'm going to have to create a custom
PathEffect which can do this. Is this the correct approach? Have I
missed something glaringly obvious? Could any one give some advise
with regards to how to create custom PathEffects ?

Many thanks in advance.

Regards
--
Brad




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Fwd: Supported unicode characters

2008-12-01 Thread Mike Reed
U+2603 is not currently in the android fonts.

FYI -  The default font is DroidSans.ttf (when you don't specify a  
typeface object). All of the UI fonts (there are 7 currently) in turn  
reference DroidSansFallback.ttf for characters that they don't contain.

mike

On Nov 26, 2008, at 8:59 PM, Rui Castro wrote:

Hi,

I already sent this message to android-framework group, but since I  
had no answer there I want to post the problem described bellow here.
Please read the forward message.

Thanks,
Rui

-- Forwarded message --
From: Rui Castro [EMAIL PROTECTED]
Date: Wed, Nov 26, 2008 at 11:52 PM
Subject: Re: Supported unicode characters
To: [EMAIL PROTECTED]


Hi,

Replying to myself, again, I noticed that the font used in the phone  
(the emulator) is not the ones in frameworks/base/data/fonts.
The character ☎ (U+2603) appear differently in the character map and  
in the actual application. See the attached pictures.

So, the question is, where is the default font used in the the phone  
applications?

Thanks,
Rui


On Wed, Nov 26, 2008 at 11:40 PM, Rui Castro [EMAIL PROTECTED]  
wrote:
Hi,

I'm sorry to insist on this, but I can't find an explanation for this  
problem. The Droid Sans font, from Android framework, contains the  
unicode character ⏏ (U+23CF), as the attached screenshot proves, but  
when I use it as the text of a button (in the layout XML file with  
@android:text attribute) what I see is a rectangle as you can see in  
the attached image.

Any ideias about this? What should I do?


On Wed, Nov 26, 2008 at 3:14 AM, Rui Castro [EMAIL PROTECTED]  
wrote:
Hi,

Thanks for the answer.
The characters I want to use are there, but when I use them a  
rectangle appears where the character should be :(

I'm using the strings.xml to put the buttons text, like this:
string name=arrow#x21A8;/string

  and in the layout XML file I reference this text like this
Button android:text=@string/arrow ... /

I'm I doing something wrong? I suppose I'm not, because this method  
work very well with the other characters.

Thanks,
Rui


On Wed, Nov 26, 2008 at 1:24 AM, Dan Bornstein [EMAIL PROTECTED]  
wrote:

On Tue, Nov 25, 2008 at 6:19 PM, Rui Castro [EMAIL PROTECTED]  
wrote:
  Is there a list of supported characters in Android?

You can find the fonts that are part of Android in
frameworks/base/data/fonts in the open source repository.

-dan








Screenshot-Character Map-1.pngScreenshot-Android Emulator  
(5554)_call.png


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Drawing a circle outline? (not a filled circle)

2008-11-12 Thread Mike Reed

The latter (canvas.drawCircle) his definitely more efficient, both  
from a garbage-collection p.o.v., and it gives the renderer the chance  
to take whatever shortcuts it can, since it knows what you're trying  
to draw (as opposed to an arbitrary path).


On Nov 12, 2008, at 12:34 PM, Greg wrote:


You need the style set to STROKE as Peli mentions.  You can also use
canvas.drawCircle() directly instead of creating a path and adding a
circle to the path.  Not sure which is more efficient, but you can at
least drop 2 lines of code from your chunk there.

Greg




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: fontspacint about drawText

2008-11-06 Thread Mike Reed

drawText only draws a single line, so vertical spacing is always done  
by the application/view (getFontSpacing returns suggested values for  
that).

Horizontal spacing happens in several ways:

- Paint.setTextScaleX() lets you apply a multiplier to all of the  
widths in the text (making it narrower or wider)
- Canvas.drawText() and drawTextOnPath() uses the font's spacing  
(modulo setTextScaleX)
- Canvas.drawPosText() lets you specify the x,y position of every  
character.

On Nov 4, 2008, at 8:00 AM, Narwal wrote:


Hello all
i know there is a method getFontSpacing().
but which method i should use,if i want to control the fontspacing
accurately,when i use drawText.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Question about View, Canvas, and Drawable.. --Basics

2008-11-06 Thread Mike Reed

Views - yes

Canvas - you can create your own to draw into a bitmap, but views are  
handed a Canvas on their onDraw() method. For a given drawing pass,  
all of the views (usually) are handed the same Canvas (which points to  
the screen). However, on a subsetquent call to onDraw(), the actual  
Canvas object may be different (even if it also points to the screen).

Drawable - this is an abstraction for something that knows how to draw  
itself inside its bounds. There are lots of subclasses (you can create  
your own), including one that wrapps a Bitmap

Bitmap - this is a basic drawing primitive that can be drawn into a  
Canvas, and/or can be the target of a Canvas. It has basic dimensions  
and a reference to memory for pixels (either the screen or to  
offscreen memory)


On Nov 4, 2008, at 8:42 AM, joshbeck wrote:


Hello all,

Is this correct?

View: The android screen is divided up into views. Views are basic
layout objects.

Canvas: You need to have at least one canvas if you want to do any
drawing. Each
view potentially has its own canvas.

Drawable: ---)This is where my 10:30 bedtime turns into a 2:30 am nap
in the chair before work.)
-What is the difference between a Bitmap and a Drawable?
Can Drawables only be used with ImageView Views?


Thanks for any help.
Josh Beck



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw fliped mirror image?

2008-11-03 Thread Mike Reed

canvas.drawBitmap(bitmap, matrix, ...)

This is really just a more efficient way to do...

canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.concat(matrix);
drawBitmap(bitmap, 0, 0, ...);
canvas.restore();

In the original example, the matrix had a -1 scale in X. This means  
that all X coordinates will be negated. Thus the image will draw  
flipped in X, but it will also appear to the left of the Y axis, which  
defaults to the left edge of the view. Thus the fix was to post- 
translate everything to the right by at least the width of the bitmap,  
to make it appear on screen.

Another fix could have been

matrix.setScale(-1, 1);
matrix.postTranslate(bitmap.getWidth(), 0);
canvas.drawBitmap(bitmap, matrix, ...);

mike


On Nov 3, 2008, at 10:46 AM, Guolong wrote:


thanks, it do work.


On Nov 3, 1:44 pm, Romain Guy [EMAIL PROTECTED] wrote:
  sprite =
 BitmapFactory 
 .decodeResource(appContext.getResources(),R.drawable.spritegfx);
  canvas.save();
  canvas.scale(-1.0f, 1.0f);
  canvas.drawBitmap(sprite, 0,0, null);
  canvas.restore();

 This will work but you also need to translate the image too. You are
 just drawing it outside of the canvas.



 On Sun, Nov 2, 2008 at 8:42 AM, Guolong [EMAIL PROTECTED]  
 wrote:

 hello,

 I want to draw a fliped image and try following code:

  sprite =
 BitmapFactory 
 .decodeResource(appContext.getResources(),R.drawable.spritegfx);
  Matrix temp1=new Matrix();
  temp1.preScale(-1.0f,1.0f);
  canvas.drawBitmap(sprite, temp1, null);

 But it does not work. neither work for the following code:

  sprite =
 BitmapFactory 
 .decodeResource(appContext.getResources(),R.drawable.spritegfx);
  canvas.save();
  canvas.scale(-1.0f, 1.0f);
  canvas.drawBitmap(sprite, 0,0, null);
  canvas.restore();

 Any idea for this problem please?

 Any way, following code do work.
  sprite =
 BitmapFactory 
 .decodeResource(appContext.getResources(),R.drawable.spritegfx);
  Matrix temp1=new Matrix();
  temp1.preScale(-1.0f,1.0f);
  flipedSprite = Bitmap.createBitmap(sprite , 0, 0,
 sprite .getWidth(),
   sprite .getHeight(), temp1, false);
  canvas.drawBitmap(flipedSprite , 0,0, null);

 But I just don't want to create a new bitmap for every fliped image
 because there're a lot of fliped or mirrored image in my program.

 --
 Romain Guywww.curious-creature.org



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Updating Imageviews During functions

2008-10-28 Thread Mike Reed

ImageView, like all subclass of View, cannot be called from any thread  
other than the UI thread.

That said, what is the update you are try to do?

On Oct 28, 2008, at 10:24 AM, Mark Hansen wrote:


Opps.. I start the Runnable with the following:

mHandler.post(mUpdateTimeTask);

forgot to add that..

On Oct 28, 10:12 am, Mark Hansen [EMAIL PROTECTED] wrote:
 Some more info:

 I declared a handler in my class:

 private Handler mHandler = new Handler();

 Then added my runnable

 private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
 updateDisplay.sendEmptyMessage(0);
}
 };

 and have a handler that does my update...

 private Handler updateDisplay = new Handler() {
 public void handleMessage(Message msg) {
 // ImageView update is here...
 }
 };

 The image views are still not updating from what I can tell until the
 rest of the activity completes.

 I've tried variations implementing runnable and spawning threads
 (which works well with progress dialogs) and still can't get it to
 work.

 Basically I want to quickly change some ImageViews almost like an
 animation or a clock in with an activity.. is there a better method of
 doing this?

 Thanks,
 Mark

 On Oct 27, 5:44 pm, Mark Hansen [EMAIL PROTECTED] wrote:

 I have some image views I'd like to update as somethings change in a
 function in an activity.

 I can't seem to get them to refresh, at least not in away that  
 appears
 visible on the phone.

 I've tried running them in a seperate thread, and even from that
 thread using a custom handler to do the image update, but still no
 dice.

 Anyone have any tips for doing this?





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Copying an area from a drawable

2008-10-28 Thread Mike Reed

The way to copy a drawable into a bitmap is to draw it there.

void draw(Drawable dr, Bitmap bm, int left, int top) {
 Canvas c = new Canvas(bm);
 c.translate(-left, -top);
 dr.draw(canvas);
}

void loop() {
 Drawable dr = // your master drawable
 dr.setBounds(0, 0, 320, 320);
 for (int y = 0; y  10; y++) {
 for (int x = 0; x  10; x++) {
 Bitmap bm = // the bitmap at cell location (x, y)
 draw(dr, bm, x * 32, y * 32);
 }
 }
}

mike

On Oct 27, 2008, at 11:57 AM, PorkChop wrote:


OK thanks Ludwig.


On 27 Oct, 11:25, Ludwig [EMAIL PROTECTED] wrote:
 I am not entirely sure if this is what you are looking for, but the  
 Canvas
 has a method where you can specify the a source and destination  
 rectangle to
 draw from and to:
 public void 
 drawBitmap(Bitmapfile:///C:/Software/android/docs/reference/android/graphics/Bitmap.html
  
 
  bitmap, 
 Rectfile:///C:/Software/android/docs/reference/android/graphics/Rect.html 
 
  src, 
 Rectfile:///C:/Software/android/docs/reference/android/graphics/Rect.html 
 
  dst, 
 Paintfile:///C:/Software/android/docs/reference/android/graphics/Paint.html 
 
  paint)

 HTH

 Ludwig

 2008/10/26 PorkChop [EMAIL PROTECTED]



 What I am trying to achieve is breaking a drawable down into an array
 of separate bitmaps. E.g. I am passing a grid of 32x32 images (lets
 say the image is 320x320 pixels and contains a grid of 10x10 smaller
 bimap images) and i want to create an array of 100 bitmaps.

 So I need to copy from (eg) x=32, y=32, w=32,h=32 into another bitmap
 which is 32x32 pixels. Anyone got any idea how to do this? Hope I  
 have
 explained this well enough.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: image manipulation

2008-10-16 Thread Mike Reed

At the low-level, take a look at android.graphics.ColorMatrix

On Oct 16, 2008, at 8:11 PM, j wrote:


Does Android come with any package/classes for image manipulations
(e.g. contrast, brightness adjustments)?  Thanks!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: WebView loadData limitations

2008-10-15 Thread Mike Reed

The Browser app does not have permission to load a page from the SD  
card. You can write an app with a WebView, and give yourself that  
permission, but the Browser is built explicitly w/o that right for  
security reasons.

On Oct 15, 2008, at 3:41 PM, Rubicks wrote:


I am trying to get a html file stored in my sdcard image on to
webview .
I am doing something like this

myWebView.loadUrl(/sdcard/index.html);

Then I get an error on the webview as The webpage at file:///sdcard/index.html
could not be loaded as:  The requested file was not found.
But I am sure I have index.html  on my sdcard image and it is
available to the emulator. Because I see it on the File explorer.
I tried myWebView.loadUrl(file:///sdcard/index.html); as well. Still
the same problem exists.

If I have to use loadDataWithBaseUrl(), then I think, I need to
convert index.html  to a string, which I don't want to.

I could not figure out the problem.

Any one any thoughts?

Thanks.

On Oct 3, 8:37 pm, schmielson [EMAIL PROTECTED] wrote:
 Thanks a ton for your comments, Mark.  I've filed a 
 bug:http://code.google.com/p/android/issues/detail?id=929 
 .

 Best,
 Dave

 On Oct 1, 5:29 am, Mark Murphy [EMAIL PROTECTED] wrote:

 schmielson wrote:
 As it turns out, the android:layout_height=wrap_content used along
 with android:layout_weight=1 of the WebView was preventing the
 WebView from properly receiving events!  After changing the  
 WebView's
 layout_height attribute to 0px instead of wrap_content,
 shouldOverrideUrlLoading is being called and things work like a
 charm.  This bug was particularly insidious, however, since I never
 would have expected that these attributes would have altered the
 view's ability to process clicks/touches in this way.

 That is definitely strange. There might be a method to the madness
 there, but off the cuff, I don't see it.

 Do you think this is an SDK bug or a documentation bug?

 Ummm...yes. ;-)

 In other words, it depends a little on why it's not working. The fact
 that you not only see the WebView, but can interact with it,  
 suggests to
 me it's an SDK bug. However, one man's SDK bug can be an Android team
 member's documentation bug, if this is somehow expected behavior.

 I do recommend filing a bug, though, just to get this in the queue to
 get looked at.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com

 Android Training on the Ranch! -- Mar 16-20, 
 2009http://www.bignerdranch.com/schedule.shtml



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Mirror effect on TextView

2008-10-08 Thread Mike Reed

Is all of the text drawing offscreen to the left? Do you need to also  
translate to the right?

On Oct 8, 2008, at 4:57 PM, stef wrote:


HI,
Trying to write a mirror image of some text.
I created a new widget derived from TextView and the overridden
onDraw(Canvas canvas) looks like

@Override
protected void onDraw(Canvas canvas) {
canvas.scale(-1.0f, 1.0f);
super.onDraw(canvas);
}

I would expect to see the text flipped around the x axis (mirror
effect) but nothing shows up...
canvas.scale(1.0f, 1.0f) show the text as expected... what is wrong
with that code?
Thanks
Stephane



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: _SAVE_FLAGs and Canvas.save(int saveFlags)

2008-10-06 Thread Mike Reed

There are two calls that take save flags, save() and saveLayer().

Only the first two flags are meaningful for save() : MATRIX and CLIP.
The others are legal, but are ignored.

saveLayer() has more options, including
HAS_ALPHA - request that the layer has per-pixel alpha
FULL_COLOR - request that the layer has at least 8bits per component
CLIP_TO_LAYER - clip drawing to just the layer



On Mon, Oct 6, 2008 at 5:12 AM, sahn0 [EMAIL PROTECTED] wrote:

 I need a clarification on which _SAVE_FLAG values can go into save(int
 saveFlags) method.
 As I understand, I can specify only two of them - MATRIX_SAVE_FLAG and
 CLIP_SAVE_FLAG. What about other values? Are they used internally?
 Maybe they should be private then?
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: skia : error in decode file

2008-10-03 Thread Mike Reed

Can you include more of the code snippet?

On Oct 3, 2008, at 12:09 PM, Sudha wrote:


Hi I had a strange problem
I am reading the images from the sdcard which are taken using the
camera in a for loop .
1st image is coming fine
and from second image onwards
I am getting
skia  fialure readaeing
skia  jpeg setjump exit
I am reading the image as
imageShow = BitmapFactory.decodeFile(+imageNames[position]);

I tried decodeStream() ,decodeBytearay etc
same isssues repeats
but the first image is coming proper..
Plz help mee

I am using 0.9 sdk





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Working with Images

2008-10-01 Thread Mike Reed

True. If you have the large image already decoded, calling

 canvas.drawBitmap(bitmap, srcRect, dstRect, paint);

allows you to draw just a section of it (specified by srcRect). The  
above call does all the clipping etc. for you (and more efficiently  
than if you did the clipping yourself).

On Sep 30, 2008, at 10:07 PM, Steve Oldmeadow wrote:


If I understand your question correctly you just want:

Bitmap.createBitmap(Bitmap source, int x, int y, int width, int
height)

where source will be your 1500x1500 bitmap, x and y are the top left
of the sub image and width and height are the width and height of the
sub image.

Memory could be an issue though particularly if you are going to keep
a lot of sub images in memory.  Don't forget that you can draw sub
sections of an image to a canvas using clipping so maybe you don't
need to create a new sub image.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Bitmap on sdcard decodestream

2008-09-30 Thread Mike Reed

That is a correct way to call decodeStream. Are you sure the path is  
correct (i.e. are you getting a non-null fileinputstream)?

On Sep 30, 2008, at 5:17 AM, Matteo Crippa wrote:


Easy i was playing with a little app i'm developing but i've just
found a little problem... let's explain me it...

I created a sdcard and inside it I placed some jpg files.

So my data path is something like:

/sdcard/app/img/1.jpg
/sdcard/app/img/2.jpg
/sdcard/app/img/3.jpg
/sdcard/app/img/4.jpg
[...]
/sdcard/app/img/n.jpg

Now I want to create a gallery app to show out these files, I looked
at demo srcs by android sdk, but they always use imgs from
resources...

I decided to try using Bitmapfactory.decodeFile and also
Bitmapfactory.decodestream but both seems not to work fine returning a
NullPointerException

Here you are a little snippet of my app:

Java:

for(int i=0;iimgsTokens.length;i++)
   {
Log.d(+i,/sdcard/app/img/+imgsTokens[i]
+.jpg);
try
{
 FileInputStream is = new FileInputStream(new
File(/sdcard/app/img/+imgsTokens[i]+.jpg));
 BufferedInputStream bis = new
BufferedInputStream(is);
 photos[i] = BitmapFactory.decodeStream(is);
 bis.close();
 is.close();

 //photos[i] = BitmapFactory.decodeFile(/
sdcard/app/img/+imgsTokens[i]+.jpg);
}
catch(Exception e)
{
 e.printStackTrace();
}
   }




any idea how to fix?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Bitmap on sdcard decodestream

2008-09-30 Thread Mike Reed

Please file a bug for this, and attach one or more of the images and  
your code snippet. That will make it much easier to diagnose.

thanks,
mike

On Sep 30, 2008, at 9:25 AM, Matteo Crippa wrote:


Hi sahn0  thanks for the tip, but it still fails with a
NullPointerException...

I tried looking at f.isFile() and it returns true... so file exists...


On 30 Set, 12:27, sahn0 [EMAIL PROTECTED] wrote:
 Maybe it is jpg format that causing problems? Try converting images to
 png.

 On 30 сент, 16:17, Matteo Crippa [EMAIL PROTECTED] wrote:

 Easy i was playing with a little app i'm developing but i've just
 found a little problem... let's explain me it...

 I created a sdcard and inside it I placed some jpg files.

 So my data path is something like:

 /sdcard/app/img/1.jpg
 /sdcard/app/img/2.jpg
 /sdcard/app/img/3.jpg
 /sdcard/app/img/4.jpg
 [...]
 /sdcard/app/img/n.jpg

 Now I want to create a gallery app to show out these files, I looked
 at demo srcs by android sdk, but they always use imgs from
 resources...

 I decided to try using Bitmapfactory.decodeFile and also
 Bitmapfactory.decodestream but both seems not to work fine  
 returning a
 NullPointerException

 Here you are a little snippet of my app:

 Java:

 for(int i=0;iimgsTokens.length;i++)
{
 Log.d(+i,/sdcard/app/img/+imgsTokens[i]
 +.jpg);
 try
 {
  FileInputStream is = new FileInputStream(new
 File(/sdcard/app/img/+imgsTokens[i]+.jpg));
  BufferedInputStream bis = new
 BufferedInputStream(is);
  photos[i] = BitmapFactory.decodeStream(is);
  bis.close();
  is.close();

  //photos[i] = BitmapFactory.decodeFile(/
 sdcard/app/img/+imgsTokens[i]+.jpg);
 }
 catch(Exception e)
 {
  e.printStackTrace();
 }
}

 any idea how to fix?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Working with Images

2008-09-30 Thread Mike Reed

We have no API to decode a subset of an image in 1.0, so for now  
you'll have to decode the entire image (with optional subsampling)

On Sep 30, 2008, at 3:57 PM, xMemphisx [EMAIL PROTECTED] wrote:


 Hello,

 What i'm currently trying to do, is load a large image... lets say the
 dimensions are 1500x1500... but then i want to create other images
 FROM that loaded image, but in smaller portions... so for instance...
 i want to use just the pixels from [250,0] to [500,250] to make a new
 image (on the fly). How can this be accomplished?

 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Paint.setTextSize ascent descent.

2008-09-27 Thread Mike Reed

Ascent and descent are pulled from the font data, so I think stupid  
interpolations are you best bet.

On Sep 27, 2008, at 12:18 PM, skink [EMAIL PROTECTED] wrote:


 hi,

 as abs(ascent) + descent != textSize passed to setTextSize, is there
 any helper function for getting what textSize to use for given
 abs(ascent) + descent without boring/stupid interpolations or trying
 various textSizes?

 thanks,
 skink
 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Bitmap issue ...

2008-09-24 Thread Mike Reed
There is no way to write to a bitmap in its native format in 1.0, but  
you can read the values by calling copyPixelsToBuffer(). This fills  
out the buffer with whatever the native config is (alpha_8, 565, ,  
).

If you could extend the api post 1.0, what functionality would you  
like to see?

mike

On Sep 23, 2008, at 2:53 PM, Kurt Jacobs wrote:

Mike,
Thanks for the explanation.  Is there a way (method that I could  
call) that I can convert the raw bitmap
to the multiplied version because doing the setPixel?

Thanks,
Kurt


On Tue, Sep 23, 2008 at 11:34 AM, Mike Reed [EMAIL PROTECTED] wrote:

The confusion (and I will try to update the dox to make this clearer)
is that the color int is in unpremultipled form, but the internal
format for Bitmap pixels is premultiplied.

premultiplied means that the r,g,b components have already been
multiplied by their respective alpha value. Thus 50% transparent Red
would be stored as 0x8080

unpremultipled means that the r,g,b components are stored in their
raw form, independent of the alpha value. Thus 50% transparent Red
would be stored as 0x80FF

Thus when you specify 0x08040201 in unpremultiplied form (as you
should for the input to setPixels), that color is internally converted
to its premultiplied equivalent, which in this case happens to be
0x0800. When you call getPixels(), the values are converted back
to unpremultiplied form automatically, but in this case there is no
change.

mike

On Sep 23, 2008, at 10:40 AM, JakeMaui wrote:


I have a bitmap issue.  I created a simple PNG that was 1 pixel high,
16 wide pure white.
I loaded the bitmap, extracted the pixels, changed the first one and
then created a bitmap
from the altered data.  The issue is that I thought that until I save
it, I would have a raw bitmap will all the bits set as I had set
them.  I found that the bits changed.
Does anybody know what I need to do to preserve the bitmap with the
bits that I set
into it?

sample code ...
  int picw= bitmap.getWidth();
  int pich=bitmap.getHeight();
  int[] pix = new int[picw*pich];
  bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

  // It's pure white at this point.
  // I set the first byte to this but when I pull it out of the newly
constructed
  // bitmap, it's 0x800
  pix[0]=0x08040201;
  createdBitmap = Bitmap.createBitmap(picw, pich,
Bitmap.Config.ARGB_);
  createdBitmap.setPixels(pix, 0, picw, 0, 0, picw, pich);

   // get pixels of newly created bitmap
   int picw=embeddedBitmap.getWidth();
   int pich=embeddedBitmap.getHeight();
   int[] pix = new int[picw*pich];
   createdBitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

Results 
1000 0100 0010 0001 before
1000   000










--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Does Android support Chinese Traditional Language?

2008-09-23 Thread Mike Reed
Android is unicode based, so any text will need to be transcoded into  
that.
The fallback font in 1.0 supports much of the Simplified Chinese  
character set, but not complete. Are you having specific problems?

mike

On Sep 23, 2008, at 9:17 AM, Ludwig wrote:

I have at least no trouble displaying Simplified Chinese characters on  
the screen (I do not have traditional chars installed, so I cannot  
check those).
Using Eclipse I simply change my IME and type in Chinese text into the  
resource strings and they appear correctly on the screen (at least in  
default font).

Ludwig

2008/9/23 Dennis [EMAIL PROTECTED]

Does Android support Chinese Traditional Language(Big5)?







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Bitmap issue ...

2008-09-23 Thread Mike Reed

The confusion (and I will try to update the dox to make this clearer)  
is that the color int is in unpremultipled form, but the internal  
format for Bitmap pixels is premultiplied.

premultiplied means that the r,g,b components have already been  
multiplied by their respective alpha value. Thus 50% transparent Red  
would be stored as 0x8080

unpremultipled means that the r,g,b components are stored in their  
raw form, independent of the alpha value. Thus 50% transparent Red  
would be stored as 0x80FF

Thus when you specify 0x08040201 in unpremultiplied form (as you  
should for the input to setPixels), that color is internally converted  
to its premultiplied equivalent, which in this case happens to be  
0x0800. When you call getPixels(), the values are converted back  
to unpremultiplied form automatically, but in this case there is no  
change.

mike

On Sep 23, 2008, at 10:40 AM, JakeMaui wrote:


I have a bitmap issue.  I created a simple PNG that was 1 pixel high,
16 wide pure white.
I loaded the bitmap, extracted the pixels, changed the first one and
then created a bitmap
from the altered data.  The issue is that I thought that until I save
it, I would have a raw bitmap will all the bits set as I had set
them.  I found that the bits changed.
Does anybody know what I need to do to preserve the bitmap with the
bits that I set
into it?

sample code ...
  int picw= bitmap.getWidth();
  int pich=bitmap.getHeight();
  int[] pix = new int[picw*pich];
  bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

  // It's pure white at this point.
  // I set the first byte to this but when I pull it out of the newly
constructed
  // bitmap, it's 0x800
  pix[0]=0x08040201;
  createdBitmap = Bitmap.createBitmap(picw, pich,
Bitmap.Config.ARGB_);
  createdBitmap.setPixels(pix, 0, picw, 0, 0, picw, pich);

   // get pixels of newly created bitmap
   int picw=embeddedBitmap.getWidth();
   int pich=embeddedBitmap.getHeight();
   int[] pix = new int[picw*pich];
   createdBitmap.getPixels(pix, 0, picw, 0, 0, picw, pich);

Results 
1000 0100 0010 0001 before
1000   000




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Saving a bitmap

2008-09-19 Thread Mike Reed

Bitmap.compress(...)

This will write the bitmap to an OutputStream, compressed as either JPEG or PNG

On Fri, Sep 19, 2008 at 6:07 AM, Teo [EMAIL PROTECTED] wrote:

 Hi, is there a way to save the bitmap to an image file (and also load
 one from an image file) ?

 I'm working on this SDK example:
 http://code.google.com/android/samples/ApiDemos/src/com/android/samples/graphics/TouchPaint.html

 Thanks,
 Teo
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: 3D and 2D on same view

2008-09-19 Thread Mike Reed

See SurfaceViewOverlay.java sample code.

On Fri, Sep 19, 2008 at 5:00 AM, Shraddha Bhaskare
[EMAIL PROTECTED] wrote:

 Hi,

 I need to know if 2D and 3D can co-exist on the same view.
 Can we have 2D and 3D views on the same screen?

 Thanks in advance
 Shraddha

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: How float coordinates are mapped to pixels (rounded)?

2008-09-11 Thread Mike Reed

Correct

On Sep 11, 2008, at 8:27 AM, sahn0 wrote:


How exactly float coordinates are mapped to pixels (provided that
there is no transformation)?
I guess they are rounded in a good old fashion way: (int)
(floatCoordiate+0.5f). Am I correct?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: drawLine is broken

2008-09-11 Thread Mike Reed

Might be a bug. Can you put a more complete code snippet (including  
how the paint (p) was setup) into the bug?

thanks,
mike

On Sep 11, 2008, at 8:20 AM, sahn0 wrote:


Consider two ways to draw a rectangle:

//-
int x=10;
int y=10;
int w=2;
int h=2;

canvas.drawRect(x,y,x+w,y+h,p); // (1)

float[] lines=new float[]{
x,y,x+w,y,
x+w,y,x+w,y+h,
x+w,y+h,x,y+h,
x,y+h,x,y
};

canvas.drawLines(lines,p); // (2)
//-

You may think that they both produce same rectagle, but you would be
wrong.
Call (2) draws a rectangle without bottom-right pixel. (Call (1) draws
rectangle correctly.)

This is because drawLine doesn't draw endpoint's pixel. So
drawLine(0,0,2,0) draws 2 pixels, not three. Hence the missing pixel
at the bottom-right (drawLines also sorts points, so bottom line is
drawn from (x,y+h) to (x+w,y+h)).

This behaviour is different from J2ME's  J2SE's, where drawLine
always draws both endpoints, and drawing rectange with drawLine
produces same result as drawRect.

The question is: is this a bug?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: drawLine is broken

2008-09-11 Thread Mike Reed

The general confusion is that the android graphics geometry is center- 
line based, and consistent at all matrix transformations, while J2ME  
linedrawing is more pen based.

As an example, when android draws a line, it basically constructs a  
rectangle about the line, by moving parallel to the line by 1/2 the  
strokeWidth. If there is no fancy Join (e.g. Square or Round), no  
outset is performed on the line's ends. So for the line (0,0) (0,2),  
it constructs the rectangle

// assuming the strokeWidth is 1.0
 left = 0
 top = -1/2
 right = 2
 bottom = 1/2

and then tries to fill the rectangle, using the standard of rounding  
each coordinate to an int via (int)(coord + 0.5) // for positive coords

That said, in your example, the strokeWidth is 0, which is a special  
value meaning hairline. This is pretty close to 1.0, but will draw  
slightly differently at times, but much faster. (aside: hairline  
stroking always draws 1-pixel wide, regardless of the matrix on the  
canvas).

Stroking rectangles in hairline mode does a little extra work to be  
nice to try to hit all of the corners, even if the normal hairline  
drawLine path would have missed it.

But back to center-line geometry. The upshot really is, if you want to  
trivially predict what pixels will be hit for stroking, put your  
geometry on 1/2 pixel boundaries. Then when I outset by 1/2 the  
strokeWidth, the center-line pixel will always get hit.

mike

On Sep 11, 2008, at 9:12 AM, sahn0 wrote:


Yes, p is Paint object set up as follows:

Paint p=new Paint();
p.setColor(0xFF80);
p.setStyle(Paint.Style.STROKE);

Style.STROKE is needed for drawRect to actually draw rect, issue with
right-bottom pixel shows itself independently of Style.

On 11 сент, 19:48, Mike Reed [EMAIL PROTECTED] wrote:
 Might be a bug. Can you put a more complete code snippet (including
 how the paint (p) was setup) into the bug?

 thanks,
 mike




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: drawLine is broken

2008-09-11 Thread Mike Reed

/* oops, the rect example I gave is for (0,0) (2,0) */

On Sep 11, 2008, at 9:27 AM, Mike Reed wrote:


The general confusion is that the android graphics geometry is center-
line based, and consistent at all matrix transformations, while J2ME
linedrawing is more pen based.

As an example, when android draws a line, it basically constructs a
rectangle about the line, by moving parallel to the line by 1/2 the
strokeWidth. If there is no fancy Join (e.g. Square or Round), no
outset is performed on the line's ends. So for the line (0,0) (0,2),
it constructs the rectangle

// assuming the strokeWidth is 1.0
 left = 0
 top = -1/2
 right = 2
 bottom = 1/2

and then tries to fill the rectangle, using the standard of rounding
each coordinate to an int via (int)(coord + 0.5) // for positive coords

That said, in your example, the strokeWidth is 0, which is a special
value meaning hairline. This is pretty close to 1.0, but will draw
slightly differently at times, but much faster. (aside: hairline
stroking always draws 1-pixel wide, regardless of the matrix on the
canvas).

Stroking rectangles in hairline mode does a little extra work to be
nice to try to hit all of the corners, even if the normal hairline
drawLine path would have missed it.

But back to center-line geometry. The upshot really is, if you want to
trivially predict what pixels will be hit for stroking, put your
geometry on 1/2 pixel boundaries. Then when I outset by 1/2 the
strokeWidth, the center-line pixel will always get hit.

mike

On Sep 11, 2008, at 9:12 AM, sahn0 wrote:


Yes, p is Paint object set up as follows:

Paint p=new Paint();
p.setColor(0xFF80);
p.setStyle(Paint.Style.STROKE);

Style.STROKE is needed for drawRect to actually draw rect, issue with
right-bottom pixel shows itself independently of Style.

On 11 сент, 19:48, Mike Reed [EMAIL PROTECTED] wrote:
 Might be a bug. Can you put a more complete code snippet (including
 how the paint (p) was setup) into the bug?

 thanks,
 mike







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: drawLine is broken

2008-09-11 Thread Mike Reed

In some ways, android.graphics renders more like Quartz/PostScript  
than like QuickDraw/AWT

On Sep 11, 2008, at 9:41 AM, sahn0 wrote:


Thanks for the explanation.
Now I need to comprehend it :)

On 11 сент, 20:28, Mike Reed [EMAIL PROTECTED] wrote:
 /* oops, the rect example I gave is for (0,0) (2,0) */

 On Sep 11, 2008, at 9:27 AM, Mike Reed wrote:

 The general confusion is that the android graphics geometry is center-
 line based, and consistent at all matrix transformations, while J2ME
 linedrawing is more pen based.

 As an example, when android draws a line, it basically constructs a
 rectangle about the line, by moving parallel to the line by 1/2 the
 strokeWidth. If there is no fancy Join (e.g. Square or Round), no
 outset is performed on the line's ends. So for the line (0,0) (0,2),
 it constructs the rectangle

 // assuming the strokeWidth is 1.0
  left = 0
  top = -1/2
  right = 2
  bottom = 1/2

 and then tries to fill the rectangle, using the standard of rounding
 each coordinate to an int via (int)(coord + 0.5) // for positive  
 coords

 That said, in your example, the strokeWidth is 0, which is a special
 value meaning hairline. This is pretty close to 1.0, but will draw
 slightly differently at times, but much faster. (aside: hairline
 stroking always draws 1-pixel wide, regardless of the matrix on the
 canvas).

 Stroking rectangles in hairline mode does a little extra work to be
 nice to try to hit all of the corners, even if the normal hairline
 drawLine path would have missed it.

 But back to center-line geometry. The upshot really is, if you want to
 trivially predict what pixels will be hit for stroking, put your
 geometry on 1/2 pixel boundaries. Then when I outset by 1/2 the
 strokeWidth, the center-line pixel will always get hit.

 mike

 On Sep 11, 2008, at 9:12 AM, sahn0 wrote:

 Yes, p is Paint object set up as follows:

 Paint p=new Paint();
 p.setColor(0xFF80);
 p.setStyle(Paint.Style.STROKE);

 Style.STROKE is needed for drawRect to actually draw rect, issue with
 right-bottom pixel shows itself independently of Style.

 On 11 сент, 19:48, Mike Reed [EMAIL PROTECTED] wrote:

 Might be a bug. Can you put a more complete code snippet (including
 how the paint (p) was setup) into the bug?

 thanks,
 mike



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: Removal of javax.microedition.lcdui.Graphics

2008-09-11 Thread Mike Reed

True, android.graphics does not have the top/bottom feature, but with  
Paint.getFontMetrics(), you can compute all sorts of interesting  
vertical metrics for the font, and apply them to the baseline.

mike

On Sep 11, 2008, at 10:24 AM, JT wrote:


I would refrain from using any javax.microedition.* classes.

You can set alignment via android.graphics.Paint.Align, however it
does not have the same top/bottom feature as J2ME.
http://code.google.com/android/reference/android/graphics/Paint.Align.html

On Sep 10, 8:51 pm, Sudha [EMAIL PROTECTED] wrote:
 I was using M5 .Now I switched my application to SDK 0.9.
 I am getting the error on eclipse that
 the import  javax.microedition.lcdui.Graphics cannot be resolved.
 In my program I am using the
 Graphics.TOP|Grpahics.LEFT.

 Can any one help me to find
 whether that option is removed , why and anywhere else it is
 implemented ?
 Thanks



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---