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. Crop image in required shape other than rectangle
Forum Updated to NodeBB v4.3 + New Features

Crop image in required shape other than rectangle

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.6k Views 2 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.
  • yuvaramY Offline
    yuvaramY Offline
    yuvaram
    wrote on last edited by
    #1

    HI,

    How to crop a image in Qt by marking points on image. As i found cropping based on rectangle only (cropped and taken bytearray of cropped image).

    Thank you.

    Yuvaram Aligeti
    Embedded Qt Developer
    : )

    jsulmJ 1 Reply Last reply
    0
    • yuvaramY yuvaram

      HI,

      How to crop a image in Qt by marking points on image. As i found cropping based on rectangle only (cropped and taken bytearray of cropped image).

      Thank you.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @yuvaram What other shapes do you need? Why is rectangle not enough?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • yuvaramY Offline
        yuvaramY Offline
        yuvaram
        wrote on last edited by
        #3

        Thank you @jsulm
        my requirement is to crop the image for example ball (in circle shape), banana (curved shape). Shape may vary based on Object at run time. Some thing like photo shop has a feature of cropping based on marking points.

        Yuvaram Aligeti
        Embedded Qt Developer
        : )

        jsulmJ 2 Replies Last reply
        0
        • yuvaramY yuvaram

          Thank you @jsulm
          my requirement is to crop the image for example ball (in circle shape), banana (curved shape). Shape may vary based on Object at run time. Some thing like photo shop has a feature of cropping based on marking points.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @yuvaram This is actually not cropping, it is rather clipping. The picture will be still a rectangle.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • yuvaramY yuvaram

            Thank you @jsulm
            my requirement is to crop the image for example ball (in circle shape), banana (curved shape). Shape may vary based on Object at run time. Some thing like photo shop has a feature of cropping based on marking points.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @yuvaram I don't think Qt provides anything for this. You will either need to implement it by yourself or use third party library like ImageMagic or OpenCV.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

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

              Create a mask QImage mask(baseImage.size(),QImage::Format_MonoLSB); or use one of the available methods to get the mask (http://doc.qt.io/qt-5/qimage.html#createHeuristicMask, http://doc.qt.io/qt-5/qimage.html#createMaskFromColor) then iterate through every pixel and "delete" (baseImage.setPixelColor(x,y,Qt::transparent); ?) those that have a 0 in the mask

              "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
              2

              • Login

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