• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ wxImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TransferToWx

void TransferToWx(const Map& map, wxImage& wx)
{
    wx.Create(map.width * 8, map.height * 8);
    if (map.tileset->bpp == 4)
    {
        for (unsigned int i = 0; i < map.data.size(); i++)
        {
            int x = i % map.width;
            int y = i / map.width;
            int tile_id = map.data[i] & 0x3FF;
            int pal_id = (map.data[i] >> 12) & 0xF;
            const Tile& tile = map.tileset->tilesExport[tile_id];
            const PaletteBank& palette = map.tileset->paletteBanks[pal_id];
            for (unsigned int j = 0; j < TILE_SIZE; j++)
            {
                unsigned char pix = tile.pixels[j];
                if (!pix) continue;
                const auto& c = palette.At(pix);
                wx.SetRGB(x * 8 + j % 8, y * 8 + j / 8, c.r << 3, c.g << 3, c.b << 3);
            }
        }
    }
    else
    {
        for (unsigned int i = 0; i < map.data.size(); i++)
开发者ID:llau6,项目名称:World-s-Hardest-Game-Fire-Emblem-Edition,代码行数:25,代码来源:imageutil.cpp


示例2: SetImage

void wxHtmlImageCell::SetImage(const wxImage& img)
{
#if !defined(__WXMSW__) || wxUSE_WXDIB
    if ( img.IsOk() )
    {
        delete m_bitmap;

        int ww, hh;
        ww = img.GetWidth();
        hh = img.GetHeight();

        if ( m_bmpW == wxDefaultCoord)
            m_bmpW = ww;
        if ( m_bmpH == wxDefaultCoord)
            m_bmpH = hh;

        // Only scale the bitmap at the rendering stage,
        // so we don't lose quality twice
/*
        if ((m_bmpW != ww) || (m_bmpH != hh))
        {
            wxImage img2 = img.Scale(m_bmpW, m_bmpH);
            m_bitmap = new wxBitmap(img2);
        }
        else
*/
            m_bitmap = new wxBitmap(img);
    }
#endif
}
开发者ID:beanhome,项目名称:dev,代码行数:30,代码来源:m_image.cpp


示例3: SetPixels

        void Surface::SetPixels( const wxImage& image )
        {
            m_Format = Format( image );
            size_t numPixels = (size_t)m_Format.m_Pitch*m_Format.m_CanvasHeight;
            if ( m_Format.GetDepth() == 24 ) {
                m_Pixels = (void*)new char[ numPixels ];
                memcpy( m_Pixels, image.GetData(), numPixels );
            } else if ( m_Format.GetDepth() == 32 ) {
                // wx uses a screwed up image format with a separate alpha plane. We need to convert into RGBA
                m_Pixels = (void*)new char[ numPixels ];
                unsigned int sPitch  = image.GetWidth()*3;
                unsigned char* pData = image.GetData();
                unsigned char* pAlpha= image.GetAlpha();
                unsigned int aMask = m_Format.m_AMask;
                unsigned int aShift= m_Format.m_AShift;
                int w = (int)m_Format.GetWidth();
                int h = (int)m_Format.GetHeight();
                for ( int y = 0; y < h; y++ ) {
                    unsigned int *pSrc  = (unsigned int*)(pData + y*sPitch);
                    unsigned int *pDst  = (unsigned int*)((unsigned char*)m_Pixels + y*m_Format.GetPitch());
                    for ( int x = 0; x < w; x++ ) {
                        *pDst++  = ((*pSrc) & ~aMask) | ((*pAlpha) << aShift);
                        pAlpha++; pSrc = (unsigned int *)(((unsigned char*)pSrc) + 3); // performance issues with odd addresses???
                    }
                }
            } else if ( m_Format.GetDepth() == 8 ) {
                // 8 bit gray scale - downscale to gray using luma

            } else if ( m_Format.GetDepth() == 1 ) {
                // 1 bit bitmap
            } else {
                // cannot compute
                m_Pixels = NULL;
            }
        }
开发者ID:juergen0815,项目名称:PEngIneLite,代码行数:35,代码来源:wx_surface.cpp


示例4: CreateFromImage

bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{
    UnRef();

    wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
    wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )

    if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
        return false;
    
    m_refData = new wxBitmapRefData();

    if (depth == 1)
    {
        return CreateFromImageAsBitmap(image);
    }
    else
    {
#ifdef __WXGTK20__
        if (image.HasAlpha())
            return CreateFromImageAsPixbuf(image);
#endif
        return CreateFromImageAsPixmap(image);
    }
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:25,代码来源:bitmap.cpp


示例5: AdjustAndSetBitmap

void AdjustAndSetBitmap(int size, wxImage &image, wxBitmap&bitmap) {
    if (image.GetHeight() == size) {
        bitmap = wxBitmap(image);
    } else {
        wxImage scaled = image.Scale(size, size, wxIMAGE_QUALITY_HIGH);
        bitmap = wxBitmap(scaled);
    }
}
开发者ID:Jchuchla,项目名称:xLights,代码行数:8,代码来源:RenderableEffect.cpp


示例6: wxCreateGreyedImage

bool wxCreateGreyedImage(const wxImage& in, wxImage& out)
{
#if wxUSE_IMAGE
    out = in.ConvertToGreyscale();
    if ( out.IsOk() )
        return true;
#endif // wxUSE_IMAGE
    return false;
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:9,代码来源:tbarbase.cpp


示例7:

ImagePanelDyn::ImagePanelDyn(wxWindow* parent, wxImage &imageScaled, wxImage &imageNoScaled, wxPoint point, wxSize size, int style) :
wxPanel(parent, wxID_ANY, point, size, style)
{
    image0 = imageScaled.Copy();
    image1 = imageNoScaled.Copy();
    w = point.x;
    h = point.y;
    win = parent;
}
开发者ID:Nadot,项目名称:wxWherbarium,代码行数:9,代码来源:ImagePanelDyn.cpp


示例8: assert

wxImage zen::stackImages(const wxImage& img1, const wxImage& img2, ImageStackLayout dir, ImageStackAlignment align, int gap)
{
    assert(gap >= 0);
    gap = std::max(0, gap);

    const int img1Width  = img1.GetWidth ();
    const int img1Height = img1.GetHeight();
    const int img2Width  = img2.GetWidth ();
    const int img2Height = img2.GetHeight();

    int width  = std::max(img1Width,  img2Width);
    int height = std::max(img1Height, img2Height);
    switch (dir)
    {
        case ImageStackLayout::HORIZONTAL:
            width  = img1Width + gap + img2Width;
            break;

        case ImageStackLayout::VERTICAL:
            height = img1Height + gap + img2Height;
            break;
    }
    wxImage output(width, height);
    output.SetAlpha();
    ::memset(output.GetAlpha(), wxIMAGE_ALPHA_TRANSPARENT, width * height);

    auto calcPos = [&](int imageExtent, int totalExtent)
    {
        switch (align)
        {
            case ImageStackAlignment::CENTER:
                return (totalExtent - imageExtent) / 2;
            case ImageStackAlignment::LEFT:
                return 0;
            case ImageStackAlignment::RIGHT:
                return totalExtent - imageExtent;
        }
        assert(false);
        return 0;
    };

    switch (dir)
    {
        case ImageStackLayout::HORIZONTAL:
            writeToImage(img1, output, wxPoint(0,               calcPos(img1Height, height)));
            writeToImage(img2, output, wxPoint(img1Width + gap, calcPos(img2Height, height)));
            break;

        case ImageStackLayout::VERTICAL:
            writeToImage(img1, output, wxPoint(calcPos(img1Width, width), 0));
            writeToImage(img2, output, wxPoint(calcPos(img2Width, width), img1Height + gap));
            break;
    }
    return output;
}
开发者ID:YY583456235,项目名称:MinFFS,代码行数:55,代码来源:image_tools.cpp


示例9: StretchDraw

bool CFrameWnd::StretchDraw(wxDC &x_dc, wxImage &x_img, wxRect &x_rect)
{_STT();
    if ( !x_img.Ok() ) return FALSE;

	// The slow but portable way...
	wxImage cWxImage = x_img.Copy();
	cWxImage.Rescale( x_rect.GetWidth(), x_rect.GetHeight() );
	x_dc.DrawBitmap( cWxImage, x_rect.x, x_rect.y );

	return TRUE;
}
开发者ID:MangoCats,项目名称:winglib,代码行数:11,代码来源:frame_wnd.cpp


示例10: subRect

// static
ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor)
{
   ImageArray result;

   int width = src.GetWidth();
   int height = src.GetHeight();
   unsigned char *data = src.GetData();
   unsigned char *ptr = data;
   unsigned char magicRed = magicColor.Red();
   unsigned char magicGreen = magicColor.Green();
   unsigned char magicBlue = magicColor.Blue();
   bool cur, prev;
   int i, j, start;

   // Sanity check...
   if (width<=0 || height<=0 || data==NULL)
      return result;
   
   prev = false;
   start = 0;
   for(i=0; i<width+1; i++) {
      if (i < width) {
         unsigned char *ptr2 = ptr;
         cur = true;
         for(j=0; j<height && cur; j++) {
            if (!(ptr2[0] == magicRed &&
                  ptr2[1] == magicGreen &&
                  ptr2[2] == magicBlue))
               cur = false;
            ptr2 += 3 * width;
         }
      }
      else
         cur = !prev;
      
      if ((cur && !prev)) {
         wxRect subRect(start, 0, i-start, height);
         wxImage subImage;
         if (subRect.width > 0)
            subImage = src.GetSubImage(subRect);
         else
            subImage = wxImage(subRect.width, subRect.height);
         result.Add(subImage);
      }
      else if (!cur && prev) {
         start = i;
      }
      
      prev = cur;
      ptr += 3;
   }

   return result;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:55,代码来源:ImageRoll.cpp


示例11: addMipMap

static void addMipMap(GLuint* texture, const wxImage &l_Image, int &level) {
    if (l_Image.IsOk() == true)
    {
        glTexImage2D(GL_TEXTURE_2D, level, GL_RGB, (GLsizei)l_Image.GetWidth(), (GLsizei)l_Image.GetHeight(),
                     0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)l_Image.GetData());
        int err = glGetError();
        if (err == GL_NO_ERROR) {
            level++;
        }
    }
}
开发者ID:rickcowan,项目名称:xLights,代码行数:11,代码来源:DrawGLUtils.cpp


示例12: recognize

wxString Ocr::recognize(const wxImage & image) const
{
  char * text = _api->TesseractRect(image.GetData(), 
                                    3,
                                    3 * image.GetWidth(),
                                    0,
                                    0,
                                    image.GetWidth(),
                                    image.GetHeight());
  wxString outputText(text, wxConvUTF8);
  delete[] text;
  return outputText;
}
开发者ID:smallduckinette,项目名称:medoc,代码行数:13,代码来源:Ocr.cpp


示例13: GreyOutImage

void GreyOutImage(wxImage &img)
{
    unsigned char *data = img.GetData();
    unsigned char r,g,b;
    unsigned char mr,mg,mb;
    int i, tst;
    int len = img.GetHeight()*img.GetWidth()*3;
    if (img.HasMask())
    {
        mr = img.GetMaskRed();
        mg = img.GetMaskGreen();
        mb = img.GetMaskBlue();
    }
    tst=0;
    for (i=0;i<len;i+=3)
    {
        r=data[i]; g=data[i+1]; b=data[i+2];
        if (!img.HasMask() || 
            r!=mr || g!=mg || b!=mb)
        {
            if (!tst)
            {
                tst=1;
            }
            r = (unsigned char)((230.0-r)*0.7+r);
            g = (unsigned char)((230.0-g)*0.7+g);
            b = (unsigned char)((230.0-b)*0.7+b);
            data[i]=r; data[i+1]=g; data[i+2]=b;
        }
    }
}
开发者ID:goretkin,项目名称:kwc-ros-pkg,代码行数:31,代码来源:pseudodc.cpp


示例14: DoRegionUnion

static bool DoRegionUnion(wxRegion& region,
                          const wxImage& image,
                          unsigned char loR,
                          unsigned char loG,
                          unsigned char loB,
                          int tolerance)
{
    unsigned char hiR, hiG, hiB;

    hiR = (unsigned char)wxMin(0xFF, loR + tolerance);
    hiG = (unsigned char)wxMin(0xFF, loG + tolerance);
    hiB = (unsigned char)wxMin(0xFF, loB + tolerance);

    // Loop through the image row by row, pixel by pixel, building up
    // rectangles to add to the region.
    int width = image.GetWidth();
    int height = image.GetHeight();
    for (int y=0; y < height; y++)
    {
        wxRect rect;
        rect.y = y;
        rect.height = 1;

        for (int x=0; x < width; x++)
        {
            // search for a continuous range of non-transparent pixels
            int x0 = x;
            while ( x < width)
            {
                unsigned char R = image.GetRed(x,y);
                unsigned char G = image.GetGreen(x,y);
                unsigned char B = image.GetBlue(x,y);
                if (( R >= loR && R <= hiR) &&
                    ( G >= loG && G <= hiG) &&
                    ( B >= loB && B <= hiB))  // It's transparent
                    break;
                x++;
            }

            // Add the run of non-transparent pixels (if any) to the region
            if (x > x0) {
                rect.x = x0;
                rect.width = x - x0;
                region.Union(rect);
            }
        }
    }

    return true;
}
开发者ID:BackupTheBerlios,项目名称:wxbeos-svn,代码行数:50,代码来源:rgncmn.cpp


示例15: LoadBannerImage

void InfoPanel::LoadBannerImage()
{
  const wxImage banner_image = WxUtils::ToWxImage(m_game_list_item.GetBannerImage());
  const wxSize banner_min_size = m_banner->GetMinSize();

  if (banner_image.IsOk())
  {
    m_banner->SetBitmap(WxUtils::ScaleImageToBitmap(banner_image, this, banner_min_size));
    m_banner->Bind(wxEVT_RIGHT_DOWN, &InfoPanel::OnRightClickBanner, this);
  }
  else
  {
    m_banner->SetBitmap(WxUtils::LoadScaledResourceBitmap("nobanner", this, banner_min_size));
  }
}
开发者ID:delroth,项目名称:dolphin,代码行数:15,代码来源:InfoPanel.cpp


示例16: Model

ImageFrameDyn::ImageFrameDyn(wxWindow* parent, wxImage &imageScaled, wxImage &imageNoScaled, wxPoint point, wxSize size, int style) :
wxFrame(parent, wxID_ANY, "", point, size, style)
{
    
    cout << "ImageFrameDyn::ImageFrameDyn[0]" << endl;
    Model *model = new Model();
    image0 = imageScaled.Copy();
    imageZ = imageNoScaled.Copy();
    model->isImageOK("ImageFrameDyn:image0", image0, true);
    model->isImageOK("ImageFrameDyn:imageZ", imageZ, true);
//    w = point.x;
//    h = point.y;
    win = parent;
    this->Show();
}
开发者ID:Nadot,项目名称:wxEssai,代码行数:15,代码来源:ImageFrameDyn.cpp


示例17: CopyFromImage

bool usImage::CopyFromImage(const wxImage& img)
{
    Init(img.GetSize());

    const unsigned char *pSrc = img.GetData();
    unsigned short *pDest = ImageData;

    for (int i = 0; i < NPixels; i++)
    {
        *pDest++ = ((unsigned short) *pSrc) << 8;
        pSrc += 3;
    }

    return false;
}
开发者ID:xeqtr1982,项目名称:phd2,代码行数:15,代码来源:usImage.cpp


示例18: PlotImage

void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos, double aScaleFactor )
{
    wxSize size( aImage.GetWidth() * aScaleFactor,
	         aImage.GetHeight() * aScaleFactor );

    wxPoint start = aPos;
    start.x -= size.x / 2;
    start.y -= size.y / 2;

    wxPoint end = start;
    end.x += size.x;
    end.y += size.y;

    Rect( start, end, NO_FILL );
}
开发者ID:CastMi,项目名称:kicad-source-mirror,代码行数:15,代码来源:class_plotter.cpp


示例19: FreeImage_Rescale

wxImage
FreeImage_Rescale(wxImage src, wxInt32 dst_width, wxInt32 dst_height, FREE_IMAGE_FILTER filter) {

	wxImage dst;

	if ((src.Ok()) && (dst_width > 0) && (dst_height > 0)) {

		dst.Create(dst_width, dst_height);

		// select the filter
		CGenericFilter *pFilter = NULL;
		switch(filter) {
			case FILTER_BOX:
				pFilter = new CBoxFilter();
				break;
			case FILTER_BICUBIC:
				pFilter = new CBicubicFilter();
				break;
			case FILTER_BILINEAR:
				pFilter = new CBilinearFilter();
				break;
			case FILTER_BSPLINE:
				pFilter = new CBSplineFilter();
				break;
			case FILTER_CATMULLROM:
				pFilter = new CCatmullRomFilter();
				break;
			case FILTER_LANCZOS3:
				pFilter = new CLanczos3Filter();
				break;
		}
		CResizeEngine Engine(pFilter);

		// perform upsampling or downsampling
		unsigned char *pSrc = src.GetData();
		unsigned char *pDst = dst.GetData();
		wxInt32 src_width  = src.GetWidth();
		wxInt32 src_height = src.GetHeight();

		Engine.Scale(pSrc, src_width, src_height, pDst, dst_width, dst_height);

		delete pFilter;

	}

	return dst;

}
开发者ID:john-peterson,项目名称:comical,代码行数:48,代码来源:Resize.cpp


示例20: GetCanvasPixLL

void IsoLine::drawIsoLineLabels(GRIBOverlayFactory *pof, wxDC *dc,
                                PlugIn_ViewPort *vp, int density, int first,
                                wxImage &imageLabel)

{
    std::list<Segment *>::iterator it;
    int nb = first;
    wxString label;

    //---------------------------------------------------------
    // Ecrit les labels
    //---------------------------------------------------------
    wxRect prev;
    for (it=trace.begin(); it!=trace.end(); it++,nb++)
    {
        if (nb % density == 0)
        {
            Segment *seg = *it;

//            if(vp->vpBBox.PointInBox((seg->px1 + seg->px2)/2., (seg->py1 + seg->py2)/2., 0.))
            {
                wxPoint ab;
                GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
                wxPoint cd;
                GetCanvasPixLL(vp, &cd, seg->py1, seg->px1);

                int w = imageLabel.GetWidth();
                int h = imageLabel.GetHeight();

                int label_offset = 6;
                int xd = (ab.x + cd.x-(w+label_offset * 2))/2;
                int yd = (ab.y + cd.y - h)/2;

                int x = xd - label_offset;
                wxRect r(x ,yd ,w ,h);
                r.Inflate(w);
                if (!prev.Intersects(r))  {
                      prev = r;

                      /* don't use alpha for isobars, for some reason draw bitmap ignores
                         the 4th argument (true or false has same result) */
                      wxImage img(w, h, imageLabel.GetData(), true);
                      dc->DrawBitmap(img, xd, yd, false);
                }
            }
        }
    }
}
开发者ID:OpenCPN,项目名称:OpenCPN,代码行数:48,代码来源:IsoLine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ wxInitDialogEvent类代码示例发布时间:2022-05-31
下一篇:
C++ wxIdleEvent类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap