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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:09:43+00:00 2026-05-23T02:09:43+00:00

I am getting unexpected output from a piece of code that is simply accessing

  • 0

I am getting unexpected output from a piece of code that is simply accessing image coordinates, here’s a snippet:

QImage image(imageFileNames[frameNumber]);
QRgb qrgb(image.pixel(493,114));
QColor testCol(qrgb);

Using the debugger to make sure I get the right image path I get something like ../seq/0001.png, which is as expected. However, testCol has the values of:

[argb]
alpha 65535
blue 28013
green 24415
pad 0
red 59367

Instead of the expected value within the 255,255,255 range. Also, the value of qrb is 4293353325. The pixel coordinate is in image range (720×288 image) and image is in .png format (QImage::Format_RGB32).

I’ve also discovered that this problem seems to be global to the entire application and any new code that is written seems to inherit this behaviour.

Upon further experimentation, using the following code:

QRgb qrgb(image.pixel(1,1)); //again this is in range
int blue = qBlue(qrgb);
int red = qRed(qrgb);
int green = qGreen(qrgb);
QColor testCol(red,green,blue, 255);

testColor still has the wrong values. However, red, green and blue all show expected values. Seems like this is an issue with the QColor constructor? I’m not really too certain about what exactly is going on.

Any ideas what might be causing this behaviour? I am running Qt 4.7 on Ubuntu 10.10.

  • 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-23T02:09:44+00:00Added an answer on May 23, 2026 at 2:09 am

    QColor is a union of different structures. Each structure is composed of 5 unsigned shorts.

    QT uses internal bit shifting to store RGB values. So when you assign “1” as blue component it shifts it to make say 257. When you examine a QColor your debugger will show you 257 as blue component and you will get surprized !

    On the other hand when you use the blue() method of QColor you should get 1 !

    Don’t use the debugger to examine the QColor use its getter and setter methods.

    Here is an example taken from QT code. You can see the bit shifting clearly.

    QColor::QColor(QRgb color)
    {
        cspec = Rgb;
        ct.argb.alpha = 0xffff;
        ct.argb.red   = qRed(color)   * 0x101;
        ct.argb.green = qGreen(color) * 0x101;
        ct.argb.blue  = qBlue(color)  * 0x101;
        ct.argb.pad   = 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some rather unexpected behavior from hashes in ruby here's a simplified demonstration
I'm getting unexpected output from jQuery.css() ... <img src=http://placekitten.com/640/360 alt= id=original_image style=left:0px; top:0px; />
I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public
I am getting unexpected console output after array assignment in webkit browsers (Chrome 16.0.912.77
I am getting unexpected result for the below code. union { int aBuf[RMH_MAX_UNENCODED_LENGTH+sizeof(MSG_INFO)]; //4070+68=4138
I'm getting unexpected results from the round() and roundf() functions in the math.h library.
I'm getting unexpected results with this code: 'foo'.match(new RegExp('\bfoo\b')); // Returns null Why is
I am using Python 2.6 and am getting [what I think is] unexpected output
I'm getting some unexpected results calling one makefile from another. I have two makefiles,
I'm getting a slightly weird result from calling subprocess.Popen that I suspect has a

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.