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

  • Home
  • SEARCH
  • 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 7442729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:13:14+00:00 2026-05-29T11:13:14+00:00

I am writing a class for printing bitmaps to a portable bluetooth printer in

  • 0

I am writing a class for printing bitmaps to a portable bluetooth printer in Android via Mono For Android. My class is used to obtain the pixel data from the stream so that is can be sent to the printer in the correct format. Right now the class is simple, it just reads the height, width, and bits per pixel.

Using the offset it reads and returns the pixel data to the printer. Right now I am just working with 1 bit per pixel black and white images. The bitmaps I am working with are in Windows format.

Here is the original image:

Original Image (Sent as Bitmap)

Result of printing and initial attempt at flip

Here is the result of printing, the first image is without any transformation. And the second one is the result of modifying the BitArray with the following code:

        BitArray bits = new BitArray(returnBytes);
        BitArray flippedBits = new BitArray(bits);

        for (int i = 0, j = bits.Length - 1; i < bits.Length; i++, j--)
        {
            flippedBits[i] = bits[j];
        }

My Question is:

How do I flip the image vertically when I am working with a byte array. I am having trouble finding the algorithm for doing this, all examples seem to suggest using established graphics libraries which I cannot use.

Edit:

My Bitmap is saved in a 1 dimensional array, with the first rows bytes, then the second, third, etc.

  • 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-29T11:13:15+00:00Added an answer on May 29, 2026 at 11:13 am

    You need to do something like this:

    BitArray bits = new BitArray(returnBytes);
    BitArray flippedBits = new BitArray(bits);
    
    for (int i = 0; i < bits.Length; i += width) {
        for (int j = 0, k = width - 1; j < width; ++j, --k) {
            flippedBits[i + j] = bits[i + k];
        }
    }
    

    If you need to mirror picture upside-down, use this code:

    BitArray bits = new BitArray(returnBytes);
    BitArray flippedBits = new BitArray(bits);
    
    for (int i = 0, j = bits.Length - width; i < bits.Length; i += width, j -= width) {
        for (int k = 0; k < width; ++k) {
            flippedBits[i + k] = bits[j + k];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing C# application that need to print data to POS STAR printer
I am writing a class library which abstracts data contained in XML files on
I'm writing a class to represent a row from a SQL query. I want
I have a python script that is constantly grabbing data from Twitter and writing
When writing a class do you group members variables of the same type together?
I'm currently writing a class that implements the SeekableIterator interface and have run into
I'm busy writing a class that monitors the status of RAS connections. I need
I'm currently writing a class to handle all database-activity in my application, and so
I'm writing a class-library in VB.Net and one of the subs that are being
I am writing a class that is linked to an external resource. One of

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.