3

I am developing an android app which would use Facebook API to post picture on to the profile. One problem is that I don't know how to generate image dynamically using some image (from the phone) and text (generated automatically) and combine both to form one dynamic image.

Is there any package I can use or is there any way to do it java?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
SaNmm
  • 201
  • 1
  • 7
  • 14
  • Are you looking for [Capcha](http://en.wikipedia.org/wiki/CAPTCHA) like functionality ? – Santosh Sep 26 '11 at 06:25
  • no i am looking for something like some apps on fb do..they take two three pictures of people and add them to a new image with some text..so i want that kind of functionality – SaNmm Sep 26 '11 at 06:43

2 Answers2

2

You need to get your Bitmap, probably loaded from the BitmapFactory and then wrap it in a Canvas object. The Canvas object will allow you to manipulate the Bitmap. Once you are finished with the Bitmap, you can convert it to JPG with the compress method on Bitmap.

Detailed instructions on painting with Android - http://groups.google.com/group/android-developers/browse_thread/thread/ac6450c22dc88aff?pli=1 Detailed instructions for writing as a particular format - Image on canvas to JPEG file

Community
  • 1
  • 1
pimaster
  • 1,907
  • 10
  • 11
  • how do i add an image on to the empty bitmap? like first i would create and empty bitmap then assign it to canvas but how would i add image(picture from album) on the bitmap – SaNmm Sep 27 '11 at 02:08
  • the canvas method has a drawBitmap() method with various parameters to control where it is placed and how it is scaled. – pimaster Sep 27 '11 at 04:56
0

As stated in a comment below, this Java SE approach does not work.


Couldn't you simply try to draw the Image? I mean I have no idea how to do this in Android, but in Java SE:

    BufferedImage created_image = new BufferedImage(hight, width);
    Graphics2D g2d = (Graphics2D) created_image.getGraphics();
    g2d.drawImage(picOfFace1, 0, 0, null);
    g2d.drawImage(picOfFace2, 50, 0, null);
    g2d.drawString("First name", 0, 50);
    g2d.drawString("Second name", 50, 50);
    g2d.dispose();
    return created_image;

You create a new Image, draw the pics on the image, draw the String on the image, you're done =)

tobijdc
  • 1,215
  • 1
  • 14
  • 21
  • If the code for the image manipulation needs to be done on the phone, this won't work. BufferedImage is not part of the Android SDK. – pimaster Sep 26 '11 at 08:03