Congratulations to our 2022 Qt Champions!

Read a bitmap into matrix

  • Hello dear programmers,
    Well i have a bitmap i have to do a rotation with mathematical methodes to rotate the image.
    well as i searched ,there is a QBitmap class specially designed for working with bitmap but i couldn't find any special event to convert my QBitmap to QMatrix or int arrays.
    take a look at this example :

    //Open the source and create the destination bitmap 
    Graphics::TBitmap *SrcBitmap=new Graphics::TBitmap; 
    Graphics::TBitmap *DestBitmap=new Graphics::TBitmap; 
    //rotate by 90° 
    //Rotate one pixel at a time 
    for (int x=0;x<SrcBitmap->Width;x++) 
      for(int y=0;y<SrcBitmap->Height;y++) 
    //Assign the Destination bitmap to a TImage 
    delete DestBitmap; 
    delete SrcBitmap;

    i want to do something like that in Qt.
    i think im not in the right path ,any idea what to do ?

  • QMatrix is obsolete, you can use QTransform with QPixmap::transformed() to do matrix transformations on the image.

    QPixmap image("YourBitmap.bmp"); //I'm using QPixmap as I'm quite sure you don't want a monochrome bitmap but you can change it
    QTransform transformation;
    QPixmap rotadedImage= image.transformed(transformation);

  • @VRonin
    well thnQ sir for your help.
    another Question.
    i found the example above in the google ,looks like a C++ code.
    any idea what library it uses ?


  • Looks like borland specific library

Log in to reply