Dear Reader!

Android graphics is new to me and I can't get a solution for this
problem, even though I know the docs very well by now. What I wanna do
is to blend several overlapping bitmaps using a given operation like
xor or multiply. My app has a Spot class which has function to return
a generated Bitmap and a BitmapShader based on the Bitmap, plus an
attribute that stores a PorterDuff.Mode value. Could someone please
explain why the following code doesn't work? All I get is a black
empty screen, but no errors.

parts of the Spot class:

  public final Bitmap toBitmap()
  {
    Bitmap out = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
    out.eraseColor(Color.TRANSPARENT);
    Canvas layer = new Canvas(out);
    RoundRectShape rr = new RoundRectShape(new float[]{2, 2, 2, 2, 2,
2, 2, 2}, null, null);
    getPaint().setColor(color);
    rr.draw(layer, getPaint());
    return out;
  }

  public BitmapShader getShader()
  {
    return new BitmapShader(toBitmap(), Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT);
  }

...and my main View:

  @Override
  protected void onDraw(Canvas canvas)
  {
    Bitmap screen = Bitmap.createBitmap(canvas.getWidth(),
canvas.getHeight(), Bitmap.Config.ARGB_8888);
    Spot spot;
    Paint paint = new Paint();
    Canvas spotLayers = new Canvas(screen);
    for (int i=0, mi=spots.size(); i<mi; i++)
    {
      spot = getSpot(i);
      if (i > 1)
        paint.setShader(new ComposeShader(getSpot(i-1).getShader(),
spot.getShader(), spot.getXferMode()));
      else
        paint.setShader(spot.getShader());
      spotLayers.drawPaint(paint);
    }
    canvas.drawColor(Color.BLACK);
    canvas.drawBitmap(screen, 0, 0, null);
  }

I've already browsed through the API examples and all reference pages
related to graphics, but still dunno what's up. Any help would be
great!

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to