Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Read a bitmap into matrix
Forum Updated to NodeBB v4.3 + New Features

Read a bitmap into matrix

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • md2012M Offline
    md2012M Offline
    md2012
    wrote on last edited by A Former User
    #1

    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; 
    SrcBitmap->LoadFromFile("YourBitmap.bmp");
     
    //rotate by 90° 
    
    DestBitmap->Width=SrcBitmap->Height; 
    DestBitmap->Height=SrcBitmap->Width; 
    
    //Rotate one pixel at a time 
    for (int x=0;x<SrcBitmap->Width;x++) 
    { 
      for(int y=0;y<SrcBitmap->Height;y++) 
      { 
        DestBitmap->Canvas->Pixels[y][SrcBitmap->Width-1-x]= 
           SrcBitmap->Canvas->Pixels[x][y]; 
      } 
    } 
    
    //Assign the Destination bitmap to a TImage 
    Image1->Picture->Bitmap=DestBitmap; 
    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 ?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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;
      transformation.rotate(90.0);
      QPixmap rotadedImage= image.transformed(transformation);
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      md2012M 1 Reply Last reply
      1
      • VRoninV VRonin

        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;
        transformation.rotate(90.0);
        QPixmap rotadedImage= image.transformed(transformation);
        
        md2012M Offline
        md2012M Offline
        md2012
        wrote on last edited by
        #3

        @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 ?

        Graphics::TBitmap
        
        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Looks like borland specific library

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved