1
votes

Sorry for the basic question, I am just starting to use QImage for reading pixel data from an image file.

To understand the member functions, I tried to load an image file and tried to output the functions return values:

QString fileName = "pic1.bmp";
QImage myImage;
myImage.load( fileName );

std::cout << "width = "         << myImage.width() << std::endl;
std::cout << "height = "        << myImage.height() << std::endl;
std::cout << "dotspermeterX = " << myImage.dotsPerMeterX() << std::endl;
std::cout << "dotspermeterY = " << myImage.dotsPerMeterY() << std::endl;
QRectF myRect = myImage.rect();
std::cout << "rect = " << myRect.bottomLeft().x() << "," << myRect.bottomLeft().y()
      << "  " << myRect.topRight().x() << "," << myRect.topRight().y() << std::endl;

The output I got was:

width = 858
height = 608
dotspermeterX = 4724
dotspermeterY = 4724
rect = 0,608  858,0

My questions are:
1. What is the difference between dots and pixels?
2. Does QImage work only with int pixels? Can't I read sub-pixel data for better precision?

To clarify my question, Following is a zoomed bitmap image of a diagonal line and I want to read all the small pixels/dots in this line. Is this possible?
enter image description here

1

1 Answers

2
votes

As for the "dots per meter", you probably heard of "dots per inch" (or DPI). It's the same. If, for example, you have a 20 inch monitor with the horizontal resolution of X pixels, you will have Y "dots per inch" (or pixels per inch). If you then switch to a 40 inch monitor but with the same horizontal resolution X, then you have half the number of DPI, as the screen is now double as wide. So DPI (or PPI) can be seens as a measurement of the size of the pixels.

And no, I seriously doubt that QImage have any support for sub-pixel data.