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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:06:12+00:00 2026-05-23T12:06:12+00:00

How to flip a Bitmap upside down? (I need this for loading an OpenGL

  • 0

How to flip a Bitmap upside down?

(I need this for loading an OpenGL texture in another program).

Here is my failed try:

screenshot

stripe.png (courtesy of Pitr@OpenClipart):

enter image description here

Flip.java:

import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public class Flip extends UiApplication {
    public static void main(String args[]) {
        Flip app = new Flip();
        app.enterEventDispatcher();
    }

    public Flip() {
        pushScreen(new MyScreen());
    }
} 

class MyScreen extends MainScreen {
    static final Bitmap STRIPE = flip(Bitmap.getBitmapResource("stripe.png"));

    public MyScreen() {
        setTitle("Flip the bitmap");
        add(new BitmapField(STRIPE));
        add(new ButtonField("Hello world"));
    }

    static Bitmap flip(Bitmap bitmap) {
        int[] argb = new int[bitmap.getWidth() * bitmap.getHeight()];
        bitmap.getARGB(argb, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
        for (int i = 0; i < bitmap.getHeight(); i++) {
            for (int j = 0; j < bitmap.getWidth(); j++) {
                int swap = argb[i * bitmap.getWidth() + j];
                argb[(bitmap.getHeight() - 1 - i) * bitmap.getWidth() + j] = swap;
            }
        }
        bitmap.setARGB(argb, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
        return bitmap;
    }
}
  • 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-05-23T12:06:12+00:00Added an answer on May 23, 2026 at 12:06 pm

    Try using this bit of code:

        for (int y = 0; y < bitmap.getHeight() / 2; y++) {
            int upper_row = bitmap.getWidth() * y;
            int lower_row = bitmap.getWidth() * (bitmap.getHeight() - 1 - y);
            for (int x = 0; x < bitmap.getWidth(); x++) {
                int temp = argb[upper_row + x];
                argb[upper_row + x] = argb[lower_row + x];
                argb[lower_row + x] = temp;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Bitmap object that I need to sometimes flip horizontally, sometimes vertically,
I want to take an image in flip it upside down with html canvas.
I need to flip a Bitmap horizontally. I tried setting its scaleX property to
I need to flip an image so that a character faces in the right
In this question the answer was to flip on a switch that is picked
Is there a library/simple way to flip an image? Flip image like this: AABBCC
Hi I have to flip a thumpnail image before merge it with another jpeg
I have a Flip View and on this flipped view I have a UItextView,
I can flip my view by doing something like this: image.transform = CGAffineTransformMakeScale(-1, 1);
I need to create a flip book/page application. I have seen flash created flip

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.