Results 1 to 2 of 2

Thread: 8bit greyscale raw picture find painted area

  1. #1
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 8bit greyscale raw picture find painted area

    I want to find and cut out the painted area (painted means: not transparent.). Do you got any Ideas how to do that?
    Data Informations:
    unsigned char array* imageData; // (each entry = grey value of pixel)
    int imageHeight;
    int imageWidth;
    int imageSize;
    Example Code:

    Qt Code:
    1. QPixmap img(imageWidth , imageHeight);
    2. img.fill(Qt::transparent);
    3. QPainter paint(&img);
    4. paint.setCompositionMode(QPainter::CompositionMode_Source);
    5.  
    6. int currentPos;
    7.  
    8.  
    9. while(currentpos < imageDataSize)
    10. {
    11. int x = imageDataSize % imageWidth;
    12. int y = imageDataSize / imageWidth+1;
    13. int greyVal = imageData[currentPos];
    14.  
    15. paint.setPen(QColor(greyVal,greyVal,greyVal);
    16. if(hmm < 160)
    17. {
    18. paint.drawPoint(x,y);
    19. } else {
    20. paint.save();
    21. paint.setOpacity(0.0);
    22. paint.setPen(QColor(255,255,255,255));
    23. paint.drawPoint(x,y);
    24. paint.restore();
    25.  
    26. }
    27. currentPos++;
    28. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Location
    Mannheim, Germany
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: 8bit greyscale raw picture find painted area

    Detect the MinimumX, MinimumY and MaximumX, MaximumY non transparent Pixels and create a QRect.
    There is copyRect method for QImage...

Similar Threads

  1. Replies: 3
    Last Post: 8th March 2012, 23:51
  2. Save greyscale image
    By Lele in forum Qt Programming
    Replies: 8
    Last Post: 12th August 2008, 08:59
  3. QImage-Greyscale-8-bits-pixel
    By Ivan Labrador in forum Newbie
    Replies: 5
    Last Post: 3rd August 2008, 00:08
  4. RGB values greater than 8bit & QColor?
    By smacchia in forum Newbie
    Replies: 11
    Last Post: 21st March 2007, 14:40
  5. 8bit Color
    By Rayven in forum Qt Programming
    Replies: 4
    Last Post: 10th August 2006, 19:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.