当前位置: 首页>>代码示例>>C++>>正文


C++ QBitmap::toImage方法代码示例

本文整理汇总了C++中QBitmap::toImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap::toImage方法的具体用法?C++ QBitmap::toImage怎么用?C++ QBitmap::toImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QBitmap的用法示例。


在下文中一共展示了QBitmap::toImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: xand

QBitmap basicSegmentation::xand(QBitmap am, QBitmap bm) {
  int x, y, ap, bp;
  QImage a = am.toImage();
  QImage b = bm.toImage();
  QImage r = QImage(am.width(), am.height(), QImage::Format_Mono);
  for(x=0; x < am.width(); x++) {
    for(y=0;y < am.height(); y++) {
 	  ap=qRed(a.pixel(x,y));
 	  bp=qRed(b.pixel(x,y));
	  if(ap == 0 && bp == 0){  		  	
	  	r.setPixel(x, y, Qt::color0);
  	  } else {
  	  	r.setPixel(x, y, Qt::color1);
 	  } 
    }
  }
  return(QBitmap::fromImage(r));
}
开发者ID:erikor,项目名称:Imagine,代码行数:18,代码来源:segmentation.cpp

示例2: setValue

void PixmapEditor::setValue(const QBitmap &aValue)
{
    mValue=QPixmap::fromImage(aValue.toImage());

    ui->valueEdit->setText(bitmapToString(aValue));
    setIcon(iconForPixmap(mValue));

    mDataType=BITMAP;
}
开发者ID:Gris87,项目名称:ObjectController,代码行数:9,代码来源:pixmapeditor.cpp

示例3: qt_createIconMask

HBITMAP qt_createIconMask(const QBitmap &bitmap)
{
    QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
    int w = bm.width();
    int h = bm.height();
    int bpl = ((w+15)/16)*2;                        // bpl, 16 bit alignment
    uchar *bits = new uchar[bpl*h];
    bm.invertPixels();
    for (int y=0; y<h; y++)
        memcpy(bits+y*bpl, bm.scanLine(y), bpl);
    HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
    delete [] bits;
    return hbm;
}
开发者ID:phen89,项目名称:rtqt,代码行数:14,代码来源:qpixmap_win.cpp

示例4: erode

QBitmap basicSegmentation::erode(QBitmap mm, int count) {
  int x, y, p, p1, p2, p3, p4, n;
  QImage m = mm.toImage();
  p=qRed(m.pixel(1,1));
  for(n=0; n < count; n++) {  	
    QImage gm = QImage(m.width(), m.height(), QImage::Format_Mono);
    for(x=0; x < m.width(); x++) {
      gm.setPixel(x, 0, Qt::color1);	
      gm.setPixel(x, m.width()-1, Qt::color1);	
    }
    for(y=1;y < (m.height()-1); y++) {
      gm.setPixel(0, y, Qt::color1);	
      gm.setPixel(m.height()-1, y, Qt::color1);	
    }
    for(x=1; x < (m.width()-1); x++) {
      for(y=1;y < (m.height()-1); y++) {
  		p=qRed(m.pixel(x,y));
	    if(p == 0){  		  	
  		  p1 = qRed(m.pixel(x-1, y));
  		  p2 = qRed(m.pixel(x+1, y));
  		  p3 = qRed(m.pixel(x, y-1));
  		  p4 = qRed(m.pixel(x, y+1));
  		  if(p1 == 255 || p2 == 255 || p3 == 255 || p4 == 255) {
	  	     gm.setPixel(x,y, Qt::color1);  			      	
 		  } else {
	  	     gm.setPixel(x,y, Qt::color0);  			      
	   	  }  
 		 } else {
	  	   gm.setPixel(x,y, Qt::color1);  			       		    	
	     }
        }
      }
     m = gm;
  }
  return(QBitmap::fromImage(m));
}
开发者ID:erikor,项目名称:Imagine,代码行数:36,代码来源:segmentation.cpp

示例5: find

QIntMatrix basicSegmentation::find(QBitmap mask, int minsize)
{
  int y, x, a, l, t, eqI, eqTI, eqV, w, h, eqMaxI=1, newID = 2;
  bool done;
  QIntMatrix r(mask.width(), mask.height());
  QImage im = mask.toImage();
  QVector<int> u, eq, counts;
  w = mask.width();
  h = mask.height();
     
  for(y = 0; y < h; y++) {
    for(x = 0; x < w; x++) {
      a = qRed(im.pixel(x, y));
      if(a == 0) {
        r.set(x, y, 1);      	
      } else {
      	r.set(x, y, 0);
      }
    }
  }


  eq =  QVector<int>(2);
  counts =  QVector<int>(2);
  for(y = 1; y < (h - 1); y++) {
    for(x = 1; x < (w - 1); x++) {
      a = r.at(x, y-1);
      l = r.at(x-1, y);
      t = r.at(x, y);
      if (t == 1) {
        if (a == l && a > 1) {
          r.set(x, y, a);
          if(a > (counts.size()-1)) {
          	counts.resize(a+1);
          }
          counts[a]++;
        } else if (a != l && a > 1 && l > 1) {
          r.set(x, y, mathmin(a, l));
          if(mathmin(a, l) > (counts.size()-1)) {
          	counts.resize(mathmin(a, l)+1);
          }
          counts[mathmin(a, l)]++;
          eqI = mathmax(a,l);
          eqV = mathmin(a,l);
          done = false;
          while (!done) {
            if (eqI > eqMaxI) {
              eq.resize(eqI+1);
              eqMaxI = eqI;
            }
            if ((eq.at(eqI) > 1)) {
              if (eqV != eq.at(eqI)) {
                eqTI = eqI;
                eqI = mathmax(eqV, eq.at(eqTI));
                eqV = mathmin(eqV, eq.at(eqTI));
                eq[eqTI] = eqV;
              } else {
                eq[eqI] = eqV;
                done = true;
              }
            } else {
              eq[eqI] = eqV;
              done = true;
            }
          }
        } else if (mathmax(a,l) > 1) {
            r.set(x, y, mathmax(a, l)); 
            if(mathmax(a, l) > (counts.size()-1)) {
            	counts.resize(mathmax(a, l)+1);
            }
            counts[mathmax(a, l)]++;
        } else  {
           r.set(x, y, newID++);
           counts.resize(newID+1);
           counts[newID]=1;
        }
      } else {
      	 r.set(x, y, 0);
      }
    }
  }

  //clean up edges 

  r.replace(1, 0);

  //resolve equivalent ids

  
  if(eqMaxI > 1) 
  {
    resolveEq(&r, eq, counts, minsize);
  }

   return(r);
}
开发者ID:erikor,项目名称:Imagine,代码行数:96,代码来源:segmentation.cpp

示例6: update


//.........这里部分代码省略.........
    case Qt::SizeAllCursor:
        sh = IDC_SIZEALL;
        break;
    case Qt::ForbiddenCursor:
        sh = IDC_NO;
        break;
    case Qt::WhatsThisCursor:
        sh = IDC_HELP;
        break;
    case Qt::BusyCursor:
        sh = IDC_APPSTARTING;
        break;
    case Qt::PointingHandCursor:
        sh = IDC_HAND;
        break;
    case Qt::BlankCursor:
    case Qt::SplitVCursor:
    case Qt::SplitHCursor:
    case Qt::OpenHandCursor:
    case Qt::ClosedHandCursor:
    case Qt::BitmapCursor: {
        QImage bbits, mbits;
        bool invb, invm;
        if (cshape == Qt::BlankCursor) {
            bbits = QImage(32, 32, QImage::Format_Mono);
            bbits.fill(0);                // ignore color table
            mbits = bbits.copy();
            hx = hy = 16;
            invb = invm = false;
        } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
            bool open = cshape == Qt::OpenHandCursor;
            QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
            QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            hx = hy = 8;
            invb = invm = false;
        } else if (cshape != Qt::BitmapCursor) {
            int i = cshape - Qt::SplitVCursor;
            QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]);
            QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            if (cshape == Qt::PointingHandCursor) {
                hx = 7;
                hy = 0;
            } else
                hx = hy = 16;
            invb = invm = false;
        } else {
            bbits = bm->toImage().convertToFormat(QImage::Format_Mono);
            mbits = bmm->toImage().convertToFormat(QImage::Format_Mono);
            invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
            invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
        }
        int n = qMax(1, bbits.width() / 8);
        int h = bbits.height();
#if !defined(Q_WS_WINCE)
        uchar* xBits = new uchar[h * n];
        uchar* xMask = new uchar[h * n];
        int x = 0;
        for (int i = 0; i < h; ++i) {
            uchar *bits = bbits.scanLine(i);
            uchar *mask = mbits.scanLine(i);
            for (int j = 0; j < n; ++j) {
                uchar b = bits[j];
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:67,代码来源:qcursor_win.cpp

示例7: createSystemCursor


//.........这里部分代码省略.........
    case Qt::SizeAllCursor:
        sh = IDC_SIZEALL;
        break;
    case Qt::ForbiddenCursor:
        sh = IDC_NO;
        break;
    case Qt::WhatsThisCursor:
        sh = IDC_HELP;
        break;
    case Qt::BusyCursor:
        sh = IDC_APPSTARTING;
        break;
    case Qt::PointingHandCursor:
        sh = IDC_HAND;
        break;
    case Qt::BlankCursor:
    case Qt::SplitVCursor:
    case Qt::SplitHCursor:
    case Qt::OpenHandCursor:
    case Qt::ClosedHandCursor:
    case Qt::BitmapCursor: {
        QImage bbits, mbits;
        bool invb, invm;
        if (cshape == Qt::BlankCursor) {
            bbits = QImage(32, 32, QImage::Format_Mono);
            bbits.fill(0);                // ignore color table
            mbits = bbits.copy();
            hx = hy = 16;
            invb = invm = false;
        } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
            bool open = cshape == Qt::OpenHandCursor;
            QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
            QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            hx = hy = 8;
            invb = invm = false;
        } else if (cshape == Qt::BitmapCursor) {
            bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono);
            mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono);
            invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
            invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
        } else { // Qt::SplitVCursor, Qt::SplitHCursor
            const QBitmap cb = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplit_bits : hsplit_bits);
            const QBitmap cm = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplitm_bits : hsplitm_bits);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            hx = hy = 16;
            invb = invm = false;
        }
        const int n = qMax(1, bbits.width() / 8);
        const int h = bbits.height();
#if !defined(Q_OS_WINCE)
        QScopedArrayPointer<uchar> xBits(new uchar[h * n]);
        QScopedArrayPointer<uchar> xMask(new uchar[h * n]);
        int x = 0;
        for (int i = 0; i < h; ++i) {
            uchar *bits = bbits.scanLine(i);
            uchar *mask = mbits.scanLine(i);
            for (int j = 0; j < n; ++j) {
                uchar b = bits[j];
                uchar m = mask[j];
                if (invb)
                    b ^= 0xff;
                if (invm)
                    m ^= 0xff;
开发者ID:3163504123,项目名称:phantomjs,代码行数:67,代码来源:qwindowscursor.cpp

示例8: qt_win_bitmapToRegion

HRGN qt_win_bitmapToRegion(const QBitmap& bitmap)
{
    HRGN region=0;
    QImage image = bitmap.toImage();
    const int MAXRECT = 256;
    struct RData {
        RGNDATAHEADER header;
        RECT rect[MAXRECT];
    };
    RData data;

#define FlushSpans \
    { \
                data.header.dwSize = sizeof(RGNDATAHEADER); \
                data.header.iType = RDH_RECTANGLES; \
                data.header.nCount = n; \
                data.header.nRgnSize = 0; \
                data.header.rcBound.bottom = y; \
                HRGN r = ExtCreateRegion(0, \
                    sizeof(RGNDATAHEADER)+n*sizeof(RECT),(RGNDATA*)&data); \
                if (region) { \
                    CombineRgn(region, region, r, RGN_OR); \
                    DeleteObject(r); \
                } else { \
                    region = r; \
                } \
                data.header.rcBound.top = y; \
        }

#define AddSpan \
        { \
            data.rect[n].left=prev1; \
            data.rect[n].top=y; \
            data.rect[n].right=x-1+1; \
            data.rect[n].bottom=y+1; \
            n++; \
            if (n == MAXRECT) { \
                FlushSpans \
                n=0; \
            } \
        }

    data.header.rcBound.top = 0;
    data.header.rcBound.left = 0;
    data.header.rcBound.right = image.width()-1;
    int n = 0;

    int zero = 0x00;

    int x, y;
    for (y = 0; y < image.height(); ++y) {
        uchar *line = image.scanLine(y);
        int w = image.width();
        uchar all=zero;
        int prev1 = -1;
        for (x = 0; x < w;) {
            uchar byte = line[x/8];
            if (x > w - 8 || byte != all) {
                for (int b = 8; b > 0 && x < w; --b) {
                    if (!(byte & 0x01) == !all) {
                        // More of the same
                    } else {
                        // A change.
                        if (all != zero) {
                            AddSpan;
                            all = zero;
                        } else {
                            prev1 = x;
                            all = ~zero;
                        }
                    }
                    byte >>= 1;
                    ++x;
                }
            } else {
                x += 8;
            }
        }
        if (all != zero) {
            AddSpan;
        }
    }
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:82,代码来源:qregion_win.cpp


注:本文中的QBitmap::toImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。