Exemplo n.º 1
0
static HWND ShowIconHeapItem( heap_list *hl, HWND parent )
{
    HWND                hdl;
    ResInfo             *info;
    BITMAPINFOHEADER    *btinfo;
    DWORD               req_size;
    WORD                width;
    WORD                height;

    info = MemAlloc( sizeof( ResInfo ) );
    if( info == NULL )
        return( NULL );
    btinfo = (BITMAPINFOHEADER *)LockResource( hl->info.ge.hBlock );
    if( btinfo->biSize == sizeof( BITMAPINFOHEADER ) ) {
        req_size = sizeof( BITMAPINFOHEADER );
        req_size += ColorCount( btinfo->biBitCount, btinfo->biClrUsed ) * sizeof( RGBQUAD );
        req_size += ( btinfo->biWidth * btinfo->biHeight ) / ( 8 / btinfo->biBitCount );
        if( req_size > hl->info.ge.dwBlockSize ) {
            MemFree( info );
            return( NULL );
        }
    }
    info->type = GD_ICON;
    info->hdl = hl->info.ge.hBlock;
    info->res = (char *)btinfo;
    hdl = MkDisplayWin( STR_ICON, parent );
    SetWindowLong( hdl, 0, (DWORD)info );
    width = GetSystemMetrics( SM_CXICON );
    height = GetSystemMetrics( SM_CYICON ) + 2 * GetSystemMetrics( SM_CYFRAME ) + GetSystemMetrics( SM_CYCAPTION );
    SetWindowPos( hdl, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER );
    ShowWindow( hdl, SW_SHOWNORMAL );
    return( hdl );
}
Exemplo n.º 2
0
void ZoomWidget::grabPixmap()
{
    if(!selWin->isVisible()) return;
    int grabWidth = (width()-rulerWidth)/m_zoomFactor +1;
    int grabHeight = (height()-rulerWidth)/m_zoomFactor +1;
    
    m_pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), selWin->getSelection().x(), selWin->getSelection().y(), grabWidth, grabHeight);

	QHash<QRgb, int> pixels;
    QImage image = m_pixmap.toImage();
    for(int x=0;x<grabWidth;x++) {
        for(int y=0;y<grabHeight;y++) {
            QRgb pixel = image.pixel(x, y);
            pixels[pixel]++;
            
        }
    }

    QList<ColorCount> colors;
    QHashIterator<QRgb, int> i(pixels);
    while (i.hasNext()) {
        i.next();
        colors.append(ColorCount(i.key(), i.value()));
    }
    qSort(colors);

    emit colorsChanged(colors);

    update();
}