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


C++ wxImage::Scale方法代码示例

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


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

示例1: wxBitmap

wxCursor::wxCursor(
  const wxImage&                    rImage
)
{
    wxImage                         vImage32 = rImage.Scale(32,32);
    int                             nWidth   = vImage32.GetWidth();
    int                             nHeight  = vImage32.GetHeight();

    //
    // Need a bitmap handle somehow
    //
    HBITMAP                      hBitmap = wxBitmap(vImage32).GetHBITMAP();
    int                          nHotSpotX = vImage32.GetOptionInt(wxCUR_HOTSPOT_X);
    int                          nHotSpotY = vImage32.GetOptionInt(wxCUR_HOTSPOT_Y);

    if (nHotSpotX < 0 || nHotSpotX >= nWidth)
            nHotSpotX = 0;
    if (nHotSpotY < 0 || nHotSpotY >= nHeight)
            nHotSpotY = 0;


    wxCursorRefData*                pRefData = new wxCursorRefData;

    m_refData = pRefData;
    pRefData->m_hCursor = (WXHCURSOR) ::WinCreatePointer( HWND_DESKTOP
                                                         ,hBitmap
                                                         ,TRUE
                                                         ,nHotSpotY
                                                         ,nHotSpotX
                                                        );

} // end of wxCursor::wxCursor
开发者ID:gitrider,项目名称:wxsj2,代码行数:32,代码来源:cursor.cpp

示例2: AdjustAndSetBitmap

void AdjustAndSetBitmap(int size, wxImage &image, wxImage &dbl, wxBitmap&bitmap) {
#ifdef __WXOSX__
    if (dbl.GetHeight() == (2 * size)) {
        bitmap = wxBitmap(dbl, -1, 2.0);
    } else if (dbl.GetHeight() > (2*size)) {
        wxImage scaled = image.Scale(size*2, size*2, wxIMAGE_QUALITY_HIGH);
        bitmap = wxBitmap(scaled, -1, 2.0);
    } else
#endif
    if (image.GetHeight() == size) {
        bitmap = wxBitmap(image);
    } else {
        wxImage scaled = image.Scale(size, size, wxIMAGE_QUALITY_HIGH);
        bitmap = wxBitmap(scaled);
    }
}
开发者ID:Jchuchla,项目名称:xLights,代码行数:16,代码来源:RenderableEffect.cpp

示例3: CreateFromImage

void wxCursor::CreateFromImage(const wxImage & image)
{
    m_refData = new wxCursorRefData;

    int w = 16;
    int h = 16;

    int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
    int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
    int image_w = image.GetWidth();
    int image_h = image.GetHeight();

    wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
                  hotSpotY >= 0 && hotSpotY < image_h,
                  _T("invalid cursor hot spot coordinates") );

    wxImage image16(image); // final image of correct size

    // if image is too small then place it in the center, resize it if too big
    if ((w > image_w) && (h > image_h))
    {
        wxPoint offset((w - image_w)/2, (h - image_h)/2);
        hotSpotX = hotSpotX + offset.x;
        hotSpotY = hotSpotY + offset.y;

        image16 = image.Size(wxSize(w, h), offset);
    }
    else if ((w != image_w) || (h != image_h))
    {
        hotSpotX = int(hotSpotX * double(w) / double(image_w));
        hotSpotY = int(hotSpotY * double(h) / double(image_h));

        image16 = image.Scale(w, h);
    }

    unsigned char * rgbBits = image16.GetData();
    bool bHasMask = image16.HasMask() ;

#if 0
    // monochrome implementation
    M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ;
    M_CURSORDATA->m_disposeHandle = true ;
    HLock( (Handle) M_CURSORDATA->m_hCursor ) ;
    CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ;
    memset( cp->data , 0 , sizeof( Bits16 ) ) ;
    memset( cp->mask , 0 , sizeof( Bits16 ) ) ;

    unsigned char mr = image16.GetMaskRed() ;
    unsigned char mg = image16.GetMaskGreen() ;
    unsigned char mb = image16.GetMaskBlue() ;
    for ( int y = 0 ; y < h ; ++y )
    {
        short rowbits = 0 ;
        short maskbits = 0 ;

        for ( int x = 0 ; x < w ; ++x )
        {
            long pos = (y * w + x) * 3;

            unsigned char r = rgbBits[pos] ;
            unsigned char g = rgbBits[pos+1] ;
            unsigned char b = rgbBits[pos+2] ;
            if ( bHasMask && r==mr && g==mg && b==mb )
            {
                // masked area, does not appear anywhere
            }
            else
            {
                if ( (int)r + (int)g + (int)b < 0x0200 )
                {
                    rowbits |= ( 1 << (15-x) ) ;
                }
                maskbits |= ( 1 << (15-x) ) ;
            }
        }
        cp->data[y] = rowbits ;
        cp->mask[y] = maskbits ;
    }
    if ( !bHasMask )
    {
        memcpy( cp->mask , cp->data , sizeof( Bits16) ) ;
    }
    cp->hotSpot.h = hotSpotX ;
    cp->hotSpot.v = hotSpotY ;
    HUnlock( (Handle) M_CURSORDATA->m_hCursor ) ;
#else
    PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap))  ;
    short extent = 16 ;
    short bytesPerPixel = 1 ;
    short depth = 8 ;
    Rect bounds = { 0 , 0 , extent , extent } ;
    CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ;
    CTabHandle newColors = GetCTable( 8 ) ;
    HandToHand((Handle *) &newColors);
    // set the values to the indices
    for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
    {
        (**newColors).ctTable[i].value = i ;
    }
    HLock( (Handle) ch) ;
//.........这里部分代码省略.........
开发者ID:Bluehorn,项目名称:wxPython,代码行数:101,代码来源:cursor.cpp

示例4: ScaleImage

void GraphSearchFrame::ScaleImage(wxImage& Image,int Width,int Height)
{
	Image.Scale(Width,Height);
}
开发者ID:pranphy,项目名称:GraphSearch,代码行数:4,代码来源:GraphSearchMain.cpp


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