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 7876263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:08:30+00:00 2026-06-03T03:08:30+00:00

I have a drawable object that is a vector. Since you can’t crop (or

  • 0

I have a drawable object that is a vector. Since you can’t crop (or clip because of ICS forced hardware acceleration) a drawable it make’s sprite animation useless.

I’m trying to convert the drawable to a bitmap with a specific size (percentage of the lowest screen dimension for best results).

The version needs to be super memory efficient of course.

What I need help with is creating the bitmap with the specific size, here’s what I got so far:

public Bitmap svgTObitmap(String name, int percentage, int screen_width, int screen_height)
{
    _resID = _context.getResources().getIdentifier( name , "raw" , _context.getPackageName());
    SVG svg = SVGParser.getSVGFromResource(_context.getResources(), _resID);

    Drawable drawable = svg.createPictureDrawable();

    Bitmap bmp = ((BitmapDrawable)drawable).getBitmap();

    return bmp;
}
  • 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-03T03:08:30+00:00Added an answer on June 3, 2026 at 3:08 am

    Being from a vector, clearly your Drawable is not in fact a BitmapDrawable. You need to instead draw the Drawable on a Bitmap. See this answer I gave to another question:

    Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bmp); 
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    

    Obviously in your case you would specify the size you want explicitly instead of trying to get the intrinsic height/width of the drawable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?
I have an ImageView object that I'm setting the android:src=@drawable/some_xml_file instead of a standard
I have a picture in res/drawable directory: res/drawable/picture.jpeg. Can I dynamically update this picture.jpeg
I have the following code that will rotate a drawable by a set amount
I'm working on an android application, and I have a drawable that I'm loading
I have this code that should move an object down but it stands still
I'm defining a class that sets a Drawable attribute in an object. The problem
I have a class where i have an Drawable as an member. This class
I have an XML file in the drawable-folder. I want parse the XML-file using
I have a clickable TextView with a drawable as its background. I'm looking for

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.