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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:41:02+00:00 2026-06-08T06:41:02+00:00

I have a custom view and i am using onDraw() to draw onto my

  • 0

I have a custom view and i am using onDraw() to draw onto my canvas. I am drawing an image on this canvas.

I want to turn the image upside down kinda like flip on a horizontal line as a reference. This is not the same as rotating the image by 180 deg or -180 deg.

Likewise, i want to mirror or flip sidways i.e with a vertical line as it’s pivot or reference. Again this is not the same as the canvas.rotate() provides.

I am wondering how to do it. Should i use a matrix or does canvas provide any method to do it like that of a “rotate”.

Thanks.

  • 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-08T06:41:03+00:00Added an answer on June 8, 2026 at 6:41 am

    You cannot do it with Canvas directly. You will need to actually modify the Bitmap (using Matrix) before drawing it. Luckily, it’s a very simple code to do this:

    public enum Direction { VERTICAL, HORIZONTAL };
    
    /**
        Creates a new bitmap by flipping the specified bitmap
        vertically or horizontally.
        @param src        Bitmap to flip
        @param type       Flip direction (horizontal or vertical)
        @return           New bitmap created by flipping the given one
                          vertically or horizontally as specified by
                          the <code>type</code> parameter or
                          the original bitmap if an unknown type
                          is specified.
    **/
    public static Bitmap flip(Bitmap src, Direction type) {
        Matrix matrix = new Matrix();
    
        if(type == Direction.VERTICAL) {
            matrix.preScale(1.0f, -1.0f);
        }
        else if(type == Direction.HORIZONTAL) {
            matrix.preScale(-1.0f, 1.0f);
        } else {
            return src;
        }
    
        return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom view in my app that I draw using the onDraw()
I currently have a custom view whose color is set using the following, canvas.drawColor(Color.RED);
I'm having an issue using the canvas.drawText() method. I have a custom view, as
I have seen that in Cocoa I can create a custom view using drawing
I have a custom view which I override the onDraw method to draw bitmaps
i have prepared one custom view using onDraw method, my view class is, public
I have a custom status item view where I draw a string using NSString
So I created a custom text view using core graphics and have it conformed
I'm using Drupal 6. I have a custom view that needs to be filtered
I have a custom view with several NSTextField controls for which I want to

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.