Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Read a bitmap into matrix

    General and Desktop
    2
    4
    936
    Loading More Posts
    • 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.
    • M
      md2012 last edited by A Former User

      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 Reply Quote 0
      • V
        VRonin last edited by

        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

        M 1 Reply Last reply Reply Quote 1
        • M
          md2012 @VRonin last edited by

          @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 Reply Quote 0
          • V
            VRonin last edited by

            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 Reply Quote 0
            • First post
              Last post