Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9038717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:33:18+00:00 2026-06-16T09:33:18+00:00

I’ve been trying to improve this simple app which adds a text (hola) to

  • 0

I’ve been trying to improve this simple app which adds a text (“hola”) to a picture taken by the Android Camera App and the saves the image to the sd card.

However, i have only managed to add the text to the thumbnail image from the returned data, and save the file to sd card.

Could anyone point me in the right direction to do the exact same thing but with the full-size photo?

Thanks a lot!!

What I have so far: (using code from tutorials and answers to similar questions on stackoverflow)

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button captureBtn = (Button)findViewById(R.id.capture_btn);
    captureBtn.setOnClickListener(this);

}

public void onClick(View v) {
    if (v.getId() == R.id.capture_btn) {

        try {
            Intent tomaFotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(tomaFotoIntent, CAMERA_CAPTURE);
        } 
        catch(ActivityNotFoundException anfe){
            String errorMessage = "Device doesn't support capturing images";
            Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
            toast.show();
        }
    }
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        //user is returning from capturing an image using the camera
        if(requestCode == CAMERA_CAPTURE){
            //get the Uri for the captured image
            picUri = data.getData();
            //get the returned data
            Bundle extras = data.getExtras();
            //get the cropped bitmap
            Bitmap thePic = extras.getParcelable("data");
            //agregamos texto
            bmConTexto = writeTextOnDrawable(thePic, "hola");

            //guardamos la nueva imagen
            saveBitmap(bmConTexto.getBitmap());

            //retrieve a reference to the ImageView
            ImageView picView = (ImageView)findViewById(R.id.picture);
            //display the returned cropped image
            picView.setImageBitmap(bmConTexto.getBitmap());
        }
    }
}

private BitmapDrawable writeTextOnDrawable(Bitmap thePic, String text) {

    Bitmap bm = thePic.copy(Bitmap.Config.ARGB_8888, true);
    Typeface tf = Typeface.create("Helvetica", Typeface.BOLD);

    Paint paint = new Paint();
    paint.setStyle(Style.FILL);
    paint.setColor(Color.WHITE);
    paint.setTypeface(tf);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(20);

    Rect textRect = new Rect();
    paint.getTextBounds(text, 0, text.length(), textRect);

    Canvas canvas = new Canvas(bm);
    //Calculate the positions
    int xPos = (canvas.getWidth() / 2) - 2;     //-2 is for regulating the x position offset
    //"- ((paint.descent() + paint.ascent()) / 2)" is the distance from the baseline to the center.
    int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)) ;  
    canvas.drawText(text, xPos, yPos, paint);
    return new BitmapDrawable(getResources(), bm);


}

public void saveBitmap(Bitmap bm)
{
    try
    {
        String mBaseFolderPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/";
        String mFilePath = mBaseFolderPath + "abcd.jpg";

        FileOutputStream stream = new FileOutputStream(mFilePath);
        bm.compress(CompressFormat.JPEG, 100, stream);
        stream.flush();
        stream.close();
    }
    catch(Exception e)
    {
        Log.e("Could not save", e.toString());
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:33:20+00:00Added an answer on June 16, 2026 at 9:33 am

    It sounds like you are trying to take a picture and write “Hola” on it, if this is the case have you tried looking in to takePicture() of the android camera api? If not can you elaborate the question?

    Edit: pasted from the top of the page of the link above:

    To take pictures with this class, use the following steps:

    1. Obtain an instance of Camera from open(int).
    2. Get existing (default) settings with getParameters().
    3. If necessary, modify the returned Camera.Parameters object and call setParameters(Camera.Parameters).
    4. If desired, call setDisplayOrientation(int).
    5. Important: Pass a fully initialized SurfaceHolder to setPreviewDisplay(SurfaceHolder). Without a surface, the camera will be unable to start the preview.
    6. Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture.
    7. When you want, call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback) to capture a photo. Wait for the callbacks to provide the actual image data.
    8. After taking a picture, preview display will have stopped. To take more photos, call startPreview() again first.
    9. Call stopPreview() to stop updating the preview surface.
    10. Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in onPause() (and re-open() it in onResume()).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am writing an app for my school newspaper, which is run completely online
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.