// Get the bitmap wxBitmap wxImageList::GetBitmap(int index) const { #if wxUSE_WXDIB && wxUSE_IMAGE int bmp_width = 0, bmp_height = 0; GetSize(index, bmp_width, bmp_height); wxBitmap bitmap(bmp_width, bmp_height); wxMemoryDC dc; dc.SelectObject(bitmap); // draw it the first time to find a suitable mask colour ((wxImageList*)this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT); dc.SelectObject(wxNullBitmap); // find the suitable mask colour wxImage image = bitmap.ConvertToImage(); unsigned char r = 0, g = 0, b = 0; image.FindFirstUnusedColour(&r, &g, &b); // redraw whole image and bitmap in the mask colour image.Create(bmp_width, bmp_height); image.Replace(0, 0, 0, r, g, b); bitmap = wxBitmap(image); // redraw icon over the mask colour to actually draw it dc.SelectObject(bitmap); ((wxImageList*)this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT); dc.SelectObject(wxNullBitmap); // get the image, set the mask colour and convert back to get transparent bitmap image = bitmap.ConvertToImage(); image.SetMaskColour(r, g, b); bitmap = wxBitmap(image); #else wxBitmap bitmap; #endif return bitmap; }
void RedrawPanel(wxClientDC* dc) { //------------ //do the 3d work.. engine.polylist = &viewer3d_state->polylist; engine.vertlist = &viewer3d_state->vertlist; engine.indexlist = &viewer3d_state->indexlist; engine.screen = _screen; engine.screenColor = _screenColor; engine.width = kViewportWidth; engine.height = kViewportHeight; engine.updateFogTable(); engine.initFramebuffer(kViewportWidth,kViewportHeight,gfx3d.state.enableClearImage?true:false); engine.updateToonTable(); engine.updateFloatColors(); engine.performClipping(checkMaterialInterpolate->IsChecked()); engine.performViewportTransforms<true>(kViewportWidth,kViewportHeight); engine.performBackfaceTests(); engine.performCoordAdjustment(false); engine.setupTextures(false); _HACK_Viewer_ExecUnit(&engine); //------------ //dc.SetBackground(*wxGREEN_BRUSH); dc.Clear(); u8 framebuffer[kViewportWidth*kViewportHeight*3]; for(int y=0,i=0;y<kViewportHeight;y++) for(int x=0;x<kViewportWidth;x++,i++) { framebuffer[i*3] = _screenColor[i].r<<2; framebuffer[i*3+1] = _screenColor[i].g<<2; framebuffer[i*3+2] = _screenColor[i].b<<2; } wxImage image(kViewportWidth,kViewportHeight,framebuffer,true); wxBitmap bitmap(image); dc->DrawBitmap(bitmap,0,0); }
bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf) { HBITMAP hbmp = *(HBITMAP *)pBuf; BITMAP bmp; if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) ) { wxLogLastError(wxT("GetObject(HBITMAP)")); } wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes); bitmap.SetHBITMAP((WXHBITMAP)hbmp); if ( !bitmap.IsOk() ) { wxFAIL_MSG(wxT("pasting/dropping invalid bitmap")); return false; } SetBitmap(bitmap); return true; }
static void __init test_pointer(void) { plain(); null_pointer(); invalid_pointer(); symbol_ptr(); kernel_ptr(); struct_resource(); addr(); escaped_str(); hex_string(); mac(); ip(); uuid(); dentry(); struct_va_format(); struct_rtc_time(); struct_clk(); bitmap(); netdev_features(); flags(); }
bool wxBitmapDataObject::SetData(size_t WXUNUSED(len), const void *buf) { #if wxUSE_WXDIB && !defined(__WXWINCE__) const BITMAPINFO * const pbmi = (const BITMAPINFO *)buf; HBITMAP hbmp = wxDIB::ConvertToBitmap(pbmi); wxCHECK_MSG( hbmp, FALSE, wxT("pasting/dropping invalid bitmap") ); const BITMAPINFOHEADER * const pbmih = &pbmi->bmiHeader; wxBitmap bitmap(pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount); bitmap.SetHBITMAP((WXHBITMAP)hbmp); // TODO: create wxPalette if the bitmap has any SetBitmap(bitmap); return true; #else wxUnusedVar(buf); return false; #endif }
void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ) { wxSize image_size = m_canvas->GetClientSize(); wxClientDC dc( m_canvas ); wxBitmap bitmap( image_size.x, image_size.y ); wxMemoryDC memdc; memdc.SelectObject( bitmap ); memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 ); memdc.SelectObject( wxNullBitmap ); wxImage image = bitmap.ConvertToImage(); if( !image.SaveFile( aFileName, aFmt_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) ) { wxString msg; msg.Printf( _( "Can't save file \"%s\"" ), GetChars( aFileName ) ); wxMessageBox( msg ); } image.Destroy(); }
RES ResourceFormatLoaderBitMap::load(const String &p_path, const String& p_original_path, Error *r_error) { if (r_error) *r_error=ERR_FILE_CANT_OPEN; BitMap* ptr = memnew(BitMap); Ref<BitMap> bitmap( ptr ); Image image; Error err = ImageLoader::load_image(p_path,&image); ERR_EXPLAIN("Failed loading image for BitMap: "+p_path); ERR_FAIL_COND_V(err, RES()); bitmap->create_from_image_alpha(image); if (r_error) *r_error=OK; return bitmap; }
wxImage ColorInfoData::UIImage(const ColorType type, const wxSize &size) { wxASSERT((0 <= type) && (CR_SIZE > type)); checkColors(); //now fill it with the color requested wxColour color = UIColor(type); wxColour border = GLColor(type); // Create a transparent border so it's not just a blob of color. wxColour transparent = SKIN.Element(shIconTransparent); // The easiest way to do this is to just create a memory bitmap and draw // into it. wxBitmap bitmap(size.x, size.y); wxMemoryDC dc; dc.SelectObject(bitmap); // Transparent outline. dc.SetBrush(wxBrush(transparent)); dc.SetPen(wxPen(transparent)); dc.DrawRectangle(0, 0, size.x, size.y); // Border. dc.SetBrush(wxBrush(border)); dc.SetPen(wxPen(border)); dc.DrawRectangle(1, 1, size.x - 2, size.y - 2); // Color. dc.SetBrush(wxBrush(color)); dc.SetPen(wxPen(color)); dc.DrawRectangle(2, 2, size.x - 4, size.y - 4); dc.SelectObject(wxNullBitmap); return bitmap.ConvertToImage(); }
FontAtlas::FontAtlas(int bitmapSize, FontRangeMap &map, unsigned char *fontData) : bitmapSize(bitmapSize), fontRangeMap(std::move(map)) { ASSERT(bitmapSize > 0, "Invalid bitmap size"); UPtr<unsigned char[]> bitmap(new unsigned char[bitmapSize * bitmapSize]); stbtt_pack_context packContext; int res = stbtt_PackBegin(&packContext, bitmap.get(), bitmapSize, bitmapSize, 0, 1, nullptr); ASSERT(res, "stbtt_PackBegin failed"); std::vector<stbtt_pack_range> packRanges; for (std::pair<const FontType, FontRange> &item : fontRangeMap) { FontRange &fontRange = item.second; stbtt_pack_range packRange; fontRange.charData.resize(fontRange.numGlyphs); packRange.font_size = fontRange.fontSize; packRange.first_unicode_char_in_range = fontRange.firstGlyph; packRange.num_chars_in_range = fontRange.numGlyphs; packRange.chardata_for_range = fontRange.charData.data(); packRanges.push_back(packRange); } res = stbtt_PackFontRanges(&packContext, fontData, 0, packRanges.data(), packRanges.size()); ASSERT(res, "stbtt_PackFontRanges failed"); stbtt_PackEnd(&packContext); texture = std::make_shared<Texture>(GL_TEXTURE_2D); texture->bind(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, bitmapSize, bitmapSize, 0, GL_RED, GL_UNSIGNED_BYTE, bitmap.get()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); texture->unbind(); }
int main(int argc, char **argv) { // Try open/generate input.txt std::fstream f("input.txt", std::ios_base::in); if (f.fail()) { f.close(); generate_random_source(LEN); f.open("input.txt", std::ios_base::in); } if (f.fail()) { std::cerr << "Can't create/access to input file" << std::endl; return -1; } // Create the bitmap Bitmap bitmap(LEN); // Read from file filling the bitmap int tmp; f >> tmp; while (!f.eof() && !f.fail()) { bitmap.set(tmp); f >> tmp; } f.close(); // Write sorted output f.open("output.txt", std::ios_base::out); for (int i=0; i < LEN; ++i) if (bitmap.get(i)) f << i << std::endl; return 0; };
virtual void OnPaintPanelTexture( wxPaintEvent& event ) { wxPaintDC dc(wxDynamicCast(event.GetEventObject(), wxWindow)); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); int selection = GetSelectedListviewItem(listPolys); if(selection < 0) return; if(selection>=viewer3d_state->polylist.count) return; POLY& poly = viewer3d_state->polylist.list[selection]; TexCacheItem* texkey = TexCache_SetTexture(TexFormat_32bpp,poly.texParam,poly.texPalette); const u32 w = texkey->sizeX; const u32 h = texkey->sizeY; u8* const bmpdata = new u8[w*h*4]; for(u32 i=0;i<w*h;i++) { bmpdata[i*3] = texkey->decoded[i*4]; bmpdata[i*3+1] = texkey->decoded[i*4+1]; bmpdata[i*3+2] = texkey->decoded[i*4+2]; } for(u32 i=0;i<w*h;i++) bmpdata[w*h*3+i] = texkey->decoded[i*4+3]; wxImage image(w,h,false); image.InitAlpha(); image.SetData(bmpdata,true); image.SetAlpha(bmpdata+w*h*3,true); wxBitmap bitmap(image); double xscale = (double)panelTexture->GetSize().x / w; double yscale = (double)panelTexture->GetSize().y / h; dc.SetUserScale(xscale,yscale); dc.DrawBitmap(bitmap,0,0); delete[] bmpdata; }
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) int main(int _argc, char** _argv) { EEDesc desc; desc.applicationName = L"Emerald"; //窗口名称 desc.isFullScreen = false; //是否全屏 desc.width = 800; //窗口宽度 desc.height = 450; //窗口高度 desc.isSSAA = true; //是开启抗锯齿 desc.isVsync = false; //是否垂直同步 EEInitialize(); unsigned char data[5] = { 255, 2, 41, 0, 0 }; EEBitmap bitmap(1, 1, data); EEAverageC *test = new EEAverageC(EETexture(bitmap)); while (EERun()) { EEBeginScene(EEColor::BLACK); test->Process(); //int a = 1; //int b = 1; //int times = 10000000; //while (times--) //{ // a += times; // //a += times; //} printf("%f\n", EEGetDeltaTime()); EEEndScene(); } EEShutdown(); return 0; }
// ----------------------------------------------------------------------------- /// Not implemented. Forbidden and protected contructor. TBarDescr::TBarDescr(const TBarDescr& bar) : Id(bar.Id), Module(bar.Module) { GadgetFunctor = new TGadgetFunctor; SetBuilder(TGadget_FUNCTOR(CreateGadget)); Gadgets = new TBarDescrGdArray(5); BarRes = new TToolbarRes(*bar.BarRes); CHECK(BarRes->IsOK()); { // map colors TBtnBitmap bitmap(BarRes->GetBitmap(), TBtnBitmap::DefaultFaceColor, NoAutoDelete); } CelArray = new TCelArray(&BarRes->GetBitmap(), BarRes->GetCount(), TSize(BarRes->GetWidth(), BarRes->GetHeight()), TPoint(0, 0), // offset BarRes->GetBitmap().Height()/BarRes->GetHeight()); ExtractGroups(); }
// copyTo() should preserve isOpaque when it makes sense static void test_isOpaque(skiatest::Reporter* reporter, const SkBitmap& src, SkBitmap::Config dstConfig) { SkBitmap bitmap(src); SkBitmap dst; // we need the lock so that we get a valid colorTable (when available) SkAutoLockPixels alp(bitmap); SkColorTable* ctable = bitmap.getColorTable(); unsigned ctableFlags = ctable ? ctable->getFlags() : 0; if (canHaveAlpha(bitmap.config()) && canHaveAlpha(dstConfig)) { bitmap.setIsOpaque(false); if (ctable) { ctable->setFlags(ctableFlags & ~SkColorTable::kColorsAreOpaque_Flag); } REPORTER_ASSERT(reporter, bitmap.copyTo(&dst, dstConfig)); REPORTER_ASSERT(reporter, dst.config() == dstConfig); if (bitmap.isOpaque() != dst.isOpaque()) { report_opaqueness(reporter, bitmap, dst); } } bitmap.setIsOpaque(true); if (ctable) { ctable->setFlags(ctableFlags | SkColorTable::kColorsAreOpaque_Flag); } REPORTER_ASSERT(reporter, bitmap.copyTo(&dst, dstConfig)); REPORTER_ASSERT(reporter, dst.config() == dstConfig); if (bitmap.isOpaque() != dst.isOpaque()) { report_opaqueness(reporter, bitmap, dst); } if (ctable) { ctable->setFlags(ctableFlags); } }
void mainWidget::paintEvent(QPaintEvent *) { QBitmap bitmap(this->size()); bitmap.fill(); QPainter painter(&bitmap); painter.setBrush(QBrush(Qt::black)); painter.drawRoundedRect(bitmap.rect(),5,5); setMask(bitmap); QPixmap pixmap(this->size()); pixmap.fill(); painter.end(); painter.begin(&pixmap); painter.setRenderHints(QPainter::Antialiasing,true); QBrush brush; brush.setStyle(Qt::TexturePattern); brush.setTextureImage(QImage(bkPicName)); painter.setBrush(brush); painter.setPen(Qt::black); painter.drawRoundedRect(rect(),5,5); painter.end(); painter.begin(this); painter.drawPixmap(this->rect(),pixmap); }
bool UnitVideo::onRender(LPVOID world,FLOAT& x,FLOAT& y,FLOAT& z) { if(isRenderFlag() && m_dataPtr && getStat() == MEDIA_PLAY) { m_critical.lock(); if(m_initImage) { INT width = MediaSampler::getImageWidth(); INT height = MediaSampler::getImageHeight(); setSize(width,height); m_initImage = false; } INT width = MediaSampler::getImageWidth(); INT height = MediaSampler::getImageHeight(); INT pitch = (width * 24/8 + 3)/4*4; Gdiplus::Bitmap bitmap(width,height,pitch,PixelFormat24bppRGB,(LPBYTE)m_dataPtr); Gdiplus::Graphics* g = getGraphics(); g->DrawImage(&bitmap,0,height-1,width,-height); m_critical.unlock(); } return UnitGdip::onRender(world,x,y,z); }
wxBitmap WxBrowser::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin WxBrowser bitmap retrieval if (name == wxT("res/allusers.ico.gif")) { wxBitmap bitmap(_T("res/allusers.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } else if (name == wxT("res/updir.ico.gif")) { wxBitmap bitmap(_T("res/updir.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } else if (name == wxT("res/backward.ico.gif")) { wxBitmap bitmap(_T("res/backward.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } else if (name == wxT("res/more2.ico.gif")) { wxBitmap bitmap(_T("res/more2.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } else if (name == wxT("res/forward.ico.gif")) { wxBitmap bitmap(_T("res/forward.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } else if (name == wxT("res/search.ico.gif")) { wxBitmap bitmap(_T("res/search.ico.gif"), wxBITMAP_TYPE_GIF); return bitmap; } return wxNullBitmap; ////@end WxBrowser bitmap retrieval }
bool wxClipboard::AddData( wxDataObject *data ) { wxCHECK_MSG( data, false, wxT("data is invalid") ); #if wxUSE_OLE_CLIPBOARD HRESULT hr = OleSetClipboard(data->GetInterface()); if ( FAILED(hr) ) { wxLogSysError(hr, _("Failed to put data on the clipboard")); // don't free anything in this case return false; } // we have a problem here because we should delete wxDataObject, but we // can't do it because IDataObject which we just gave to the clipboard // would try to use it when it will need the data. IDataObject is ref // counted and so doesn't suffer from such problem, so we release it now // and tell it to delete wxDataObject when it is deleted itself. data->SetAutoDelete(); // we have to call either OleSetClipboard(NULL) or OleFlushClipboard() when // using OLE clipboard when the app terminates - by default, we call // OleSetClipboard(NULL) which won't waste RAM, but the app can call // wxClipboard::Flush() to chaneg this m_clearOnExit = true; return true; #elif wxUSE_DATAOBJ wxCHECK_MSG( wxIsClipboardOpened(), false, wxT("clipboard not open") ); wxDataFormat format = data->GetPreferredFormat(); switch ( format ) { case wxDF_TEXT: case wxDF_OEMTEXT: { wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxString str(textDataObject->GetText()); return wxSetClipboardData(format, str.c_str()); } case wxDF_BITMAP: case wxDF_DIB: { wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmap bitmap(bitmapDataObject->GetBitmap()); return wxSetClipboardData(data->GetPreferredFormat(), &bitmap); } #if wxUSE_METAFILE case wxDF_METAFILE: { #if 1 // TODO wxLogError(wxT("Not implemented because wxMetafileDataObject does not contain width and height values.")); return false; #else wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data; wxMetafile metaFile = metaFileDataObject->GetMetafile(); return wxSetClipboardData(wxDF_METAFILE, &metaFile, metaFileDataObject->GetWidth(), metaFileDataObject->GetHeight()); #endif } #endif // wxUSE_METAFILE default: { // This didn't compile, of course // return wxSetClipboardData(data); // TODO wxLogError(wxT("Not implemented.")); return false; } } #else // !wxUSE_DATAOBJ return false; #endif // wxUSE_DATAOBJ/!wxUSE_DATAOBJ }
Size Button::get_minimum_size_internal() { Painter *p=get_painter(); Size min; if (get_icon() >=0 && p->is_bitmap_valid( get_icon() )) { Size icon_size=p->get_bitmap_size( get_icon() ); min.width+=icon_size.width; if (min.height < icon_size.height ) min.height=icon_size.height; if (label_text!="") min.width+=constant( C_BUTTON_SEPARATION ); //if there is an icon, add the label-icon separation } min.width+=p->get_font_string_width( font( FONT_BUTTON ) , label_text ); if (p->get_font_height( font( FONT_BUTTON ) ) > min.height ) min.height=p->get_font_height( font( FONT_BUTTON ) ); if (constant( C_BUTTON_HAS_CHECKBOX )) { if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) { min.width+=constant( C_BUTTON_CHECKBOX_SIZE ); if (min.height<constant( C_BUTTON_CHECKBOX_SIZE )) min.height=constant( C_BUTTON_CHECKBOX_SIZE ); } else { Size uncheck_size=p->get_bitmap_size( bitmap( BITMAP_BUTTON_UNCHECKED ) ); min.width+=uncheck_size.width; if (min.height<uncheck_size.height) min.height=uncheck_size.height; } min.width+=constant( C_BUTTON_SEPARATION ); } if (shortcut!=0) { String s_str = Keyboard::get_code_name( shortcut ); min.width+=constant( C_BUTTON_SEPARATION ); min.width+=p->get_font_string_width( font(FONT_BUTTON), s_str ); } min.width+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_LEFT ); min.width+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_RIGHT ); min.height+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_TOP ); min.height+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_BOTTOM ); min.width+=constant( C_BUTTON_EXTRA_MARGIN )*2+constant( C_BUTTON_DISPLACEMENT ); //both margins and displacement min.height+=constant( C_BUTTON_EXTRA_MARGIN )*2+constant( C_BUTTON_DISPLACEMENT ); //both margins and displacement return min; }
BitmapID Button::get_icon() { return (icon>=0)?icon:( (bitmap( BITMAP_BUTTON_DEFAULT_ICON )>=0) ? bitmap( BITMAP_BUTTON_DEFAULT_ICON ): -1 ); }
void Button::draw(const Point& p_pos,const Size& p_size,const Rect& p_exposed) { Painter *p=get_painter(); /* Draw Outline */ //if disabled... bool draw_displaced=false; DrawMode draw_mode=get_draw_mode(); if (draw_mode==DRAW_HOVER) { //optative, otherwise draw normal if (stylebox( SB_BUTTON_HOVER ).mode!=StyleBox::MODE_NONE && (!is_toggle_mode() || (is_toggle_mode() && !is_pressed()))) { p->draw_stylebox( stylebox( SB_BUTTON_HOVER ) , Point() , p_size, p_exposed ); } else draw_mode=is_pressed()?DRAW_PRESSED:DRAW_NORMAL; } ; if (draw_mode==DRAW_NORMAL) { p->draw_stylebox( stylebox( SB_BUTTON_NORMAL ) , Point() , p_size, p_exposed ); } if (draw_mode==DRAW_PRESSED) { p->draw_stylebox( stylebox( SB_BUTTON_PRESSED ) , Point() , p_size, p_exposed ); draw_displaced=true; } Rect area_rect=Rect( p_pos, p_size ); area_rect.pos.x=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_LEFT ); area_rect.pos.y=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_TOP ); area_rect.size-=area_rect.pos; area_rect.size.x-=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_RIGHT ); area_rect.size.y-=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_BOTTOM ); area_rect.size.x-=constant( C_BUTTON_EXTRA_MARGIN )*2; area_rect.pos.x+=constant( C_BUTTON_EXTRA_MARGIN ); area_rect.size.y-=constant( C_BUTTON_EXTRA_MARGIN )*2; area_rect.pos.y+=constant( C_BUTTON_EXTRA_MARGIN ); area_rect.size.x-=constant( C_BUTTON_DISPLACEMENT ); area_rect.size.y-=constant( C_BUTTON_DISPLACEMENT ); if (draw_displaced) area_rect.pos+=Point( constant( C_BUTTON_DISPLACEMENT ), constant( C_BUTTON_DISPLACEMENT ) ); if (constant(C_BUTTON_HAS_CHECKBOX)) { Size cbsize; if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) { cbsize.width+=constant( C_BUTTON_CHECKBOX_SIZE ); cbsize.height+=constant( C_BUTTON_CHECKBOX_SIZE ); } else { cbsize=p->get_bitmap_size( bitmap( BITMAP_BUTTON_UNCHECKED ) ); } Point check_pos=area_rect.pos; check_pos.y+=(area_rect.size.height-cbsize.height)/2; if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) { p->draw_stylebox( stylebox( is_pressed() ? SB_BUTTON_CHECKED : SB_BUTTON_UNCHECKED ) , check_pos , cbsize); } else { p->draw_bitmap( bitmap( is_pressed() ? BITMAP_BUTTON_CHECKED : BITMAP_BUTTON_UNCHECKED ), check_pos ); } area_rect.pos.x+=cbsize.x+constant( C_BUTTON_SEPARATION ); area_rect.size.x-=cbsize.x+constant( C_BUTTON_SEPARATION ); } if (get_icon() >=0 && p->is_bitmap_valid( get_icon() )) { Size icon_size=p->get_bitmap_size( get_icon() ); Point icon_pos=area_rect.pos; icon_pos.y+=(area_rect.size.height-icon_size.height)/2; p->draw_bitmap( get_icon(), icon_pos ); area_rect.pos.x+=icon_size.width; area_rect.size.x-=icon_size.width; if (label_text!="") { area_rect.pos.x+=constant( C_BUTTON_SEPARATION ); //separation for the label area_rect.size.x-=constant( C_BUTTON_SEPARATION ); //separation for the label } } if (shortcut!=0) { String s_str = Keyboard::get_code_name( shortcut ); int w = p->get_font_string_width( font(FONT_BUTTON), s_str ); Point shrc_ofs= area_rect.pos; shrc_ofs.y+=(area_rect.size.height-p->get_font_height( font( FONT_BUTTON ) ))/2+p->get_font_ascent( font( FONT_BUTTON ) ); shrc_ofs.x = (area_rect.pos.x+area_rect.size.x)-w; p->draw_text( font( FONT_BUTTON ) , shrc_ofs, s_str, color(COLOR_BUTTON_SHORTCUT_FONT) ); area_rect.size.x-=w; } Point label_ofs=area_rect.pos; if (constant(C_BUTTON_LABEL_ALIGN_CENTER)) { label_ofs.x+=(area_rect.size.width-p->get_font_string_width( font( FONT_BUTTON ) , label_text ))/2; } label_ofs.y+=(area_rect.size.height-p->get_font_height( font( FONT_BUTTON ) ))/2+p->get_font_ascent( font( FONT_BUTTON ) ); p->draw_text( font( FONT_BUTTON ) , label_ofs, label_text, color(draw_mode==DRAW_HOVER?COLOR_BUTTON_FONT_HOVER:COLOR_BUTTON_FONT) ); if (accel_char >= 0) { int width = 0; for (int i=0; i<accel_char; i++) { width += p->get_font_char_width(font( FONT_BUTTON ), label_text[i]); }; p->draw_text( font( FONT_BUTTON ) , label_ofs + Point(width, 0), "_", color(COLOR_BUTTON_FONT) ); }; if (has_focus()) p->draw_stylebox( stylebox( SB_BUTTON_FOCUS ) , Point() , p_size, p_exposed); }
FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory, int flags) { FILE *handle = NULL; try { // sanity check on the parameters if (create_new) { read_only = FALSE; } // retrieve the plugin list to find the node belonging to this plugin PluginList *list = FreeImage_GetPluginList(); if (list) { PluginNode *node = list->FindNodeFromFIF(fif); if (node) { std::auto_ptr<FreeImageIO> io (new FreeImageIO); SetDefaultIO(io.get()); if (!create_new) { handle = fopen(filename, "rb"); if (handle == NULL) { return NULL; } } std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP); std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER); header->m_filename = new char[strlen(filename) + 1]; strcpy(header->m_filename, filename); header->node = node; header->fif = fif; header->io = io.get (); header->handle = handle; header->changed = FALSE; header->read_only = read_only; header->m_cachefile = NULL; header->cache_fif = fif; header->load_flags = flags; // store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure bitmap->data = header.get(); // cache the page count header->page_count = FreeImage_InternalGetPageCount(bitmap.get()); // allocate a continueus block to describe the bitmap if (!create_new) { header->m_blocks.push_back((BlockTypeS *)new BlockContinueus(0, header->page_count - 1)); } // set up the cache if (!read_only) { std::string cache_name; ReplaceExtension(cache_name, filename, "ficache"); std::auto_ptr<CacheFile> cache_file (new CacheFile(cache_name, keep_cache_in_memory)); if (cache_file->open()) { // we can use release() as std::bad_alloc won't be thrown from here on header->m_cachefile = cache_file.release(); } else { // an error occured ... fclose(handle); return NULL; } } // return the multibitmap // std::bad_alloc won't be thrown from here on header.release(); // now owned by bitmap io.release(); // now owned by bitmap return bitmap.release(); // now owned by caller } } } catch (std::bad_alloc &) { /** @todo report error */ } if (handle) fclose(handle); return NULL; }
/***************************************************** ** ** BasicWidget --- doExport ** ******************************************************/ void BasicWidget::doExport() { int exporttype; wxString filename, e; GetExportSize( &xsize, &ysize ); if ( config->showGraphicSizeDialog ) { ExportDialog dialog( this, xsize, ysize ); if ( dialog.ShowModal() != wxID_OK ) return; dialog.getSizes( xsize, ysize ); config->showGraphicSizeDialog = ! dialog.getCheckShowDialog(); } const static wxString filetypes = wxT( "PNG (*.png)|*.png|JPG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|PCX (*pcx)|*pcx|PNM (*.pnm)|*.pnm|TIFF (*.tif)|*.tif|All files (*)| *.*" ); switch ( config->defGraphicExportType ) { case 1: filename = wxT( "out.jpg" ); break; case 2: filename = wxT( "out.bmp" ); break; case 3: filename = wxT( "out.pcx" ); break; case 4: filename = wxT( "out.pnm" ); break; case 5: filename = wxT( "out.tif" ); break; default: filename = wxT( "out.png" ); break; } int style = wxFD_SAVE; if ( config->exportAskOnOverwrite ) style |= wxFD_OVERWRITE_PROMPT; wxFileDialog exportFileDialog( this, _("Export Picture" ), config->defExportPath, filename, filetypes, style, wxDefaultPosition ); exportFileDialog.SetFilterIndex( config->defGraphicExportType ); if ( exportFileDialog.ShowModal() == wxID_OK ) { filename = exportFileDialog.GetDirectory() + wxFileName::GetPathSeparator() + exportFileDialog.GetFilename(); e = exportFileDialog.GetFilename().Right(3).MakeLower(); if ( e == wxT( "png" )) { exporttype = wxBITMAP_TYPE_PNG; config->defGraphicExportType = 0; } else if ( e == wxT( "jpg" )) { exporttype = wxBITMAP_TYPE_JPEG; config->defGraphicExportType = 0; } else if ( e == wxT( "jpeg" )) { exporttype = wxBITMAP_TYPE_JPEG; config->defGraphicExportType = 0; } else if ( e == wxT( "bmp" )) { exporttype = wxBITMAP_TYPE_BMP; config->defGraphicExportType = 0; } else if ( e == wxT( "pnm" )) { exporttype = wxBITMAP_TYPE_PNM; config->defGraphicExportType = 0; } else if ( e == wxT( "pcx" )) { exporttype = wxBITMAP_TYPE_PCX; config->defGraphicExportType = 0; } else if ( e == wxT( "tif" )) { exporttype = wxBITMAP_TYPE_TIF; config->defGraphicExportType = 0; } else { doMessageBox( this, wxString::Format( _( "Can't determine image handler for extension \"%s\", using default (PNG)" ), (const wxChar*)e)); filename.Append( wxT ( ".png" )); exporttype = wxBITMAP_TYPE_PNG; config->defGraphicExportType = 0; } config->defExportPath = exportFileDialog.GetDirectory(); wxBitmap bitmap( xsize, ysize ); wxMemoryDC dc; dc.SelectObject( bitmap ); painter = new DcPainter( &dc ); exportMode = true; doPaint(); exportMode = false; delete painter; painter = 0; if ( bitmap.SaveFile( filename, (wxBitmapType)exporttype )) { doMessageBox( this, wxString::Format( _("Picture exported to %s"), (const wxChar*)filename)); } } }
MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ) : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) , m_bmpSmileXpm(smile_xpm) , m_iconSmileXpm(smile_xpm) { my_horse_ani = NULL; m_ani_images = 0 ; SetBackgroundColour(* wxWHITE); wxBitmap bitmap( 100, 100 ); wxMemoryDC dc; dc.SelectObject( bitmap ); dc.SetBrush( wxBrush( wxT("orange"), wxSOLID ) ); dc.SetPen( *wxBLACK_PEN ); dc.DrawRectangle( 0, 0, 100, 100 ); dc.SetBrush( *wxWHITE_BRUSH ); dc.DrawRectangle( 20, 20, 60, 60 ); dc.SelectObject( wxNullBitmap ); // try to find the directory with our images wxString dir; if ( wxFile::Exists(wxT("./horse.png")) ) dir = wxT("./"); else if ( wxFile::Exists(wxT("../horse.png")) ) dir = wxT("../"); else wxLogWarning(wxT("Can't find image files in either '.' or '..'!")); wxImage image = bitmap.ConvertToImage(); #if wxUSE_LIBPNG if ( !image.SaveFile( dir + wxT("test.png"), wxBITMAP_TYPE_PNG )) { wxLogError(wxT("Can't save file")); } image.Destroy(); if ( image.LoadFile( dir + wxT("test.png") ) ) my_square = wxBitmap( image ); image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_horse_png = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("toucan.png")) ) { wxLogError(wxT("Can't load PNG image")); } else { my_toucan = wxBitmap(image); } my_toucan_flipped_horiz = wxBitmap(image.Mirror(true)); my_toucan_flipped_vert = wxBitmap(image.Mirror(false)); my_toucan_flipped_both = wxBitmap(image.Mirror(true).Mirror(false)); my_toucan_grey = wxBitmap(image.ConvertToGreyscale()); my_toucan_head = wxBitmap(image.GetSubImage(wxRect(40, 7, 80, 60))); my_toucan_scaled_normal = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_NORMAL)); my_toucan_scaled_high = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_HIGH)); my_toucan_blur = wxBitmap(image.Blur(10)); #endif // wxUSE_LIBPNG #if wxUSE_LIBJPEG image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.jpg")) ) { wxLogError(wxT("Can't load JPG image")); } else { my_horse_jpeg = wxBitmap( image ); // Colorize by rotating green hue to red wxImage::HSVValue greenHSV = wxImage::RGBtoHSV(wxImage::RGBValue(0, 255, 0)); wxImage::HSVValue redHSV = wxImage::RGBtoHSV(wxImage::RGBValue(255, 0, 0)); image.RotateHue(redHSV.hue - greenHSV.hue); colorized_horse_jpeg = wxBitmap( image ); } if ( !image.LoadFile( dir + wxT("cmyk.jpg")) ) { wxLogError(wxT("Can't load CMYK JPG image")); } else { my_cmyk_jpeg = wxBitmap(image); } #endif // wxUSE_LIBJPEG #if wxUSE_GIF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.gif" )) ) { wxLogError(wxT("Can't load GIF image")); } else { my_horse_gif = wxBitmap( image ); } #endif #if wxUSE_PCX image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pcx"), wxBITMAP_TYPE_PCX ) ) { wxLogError(wxT("Can't load PCX image")); } else { my_horse_pcx = wxBitmap( image ); } #endif image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.bmp"), wxBITMAP_TYPE_BMP ) ) { wxLogError(wxT("Can't load BMP image")); } else { my_horse_bmp = wxBitmap( image ); } #if wxUSE_XPM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.xpm"), wxBITMAP_TYPE_XPM ) ) { wxLogError(wxT("Can't load XPM image")); } else { my_horse_xpm = wxBitmap( image ); } if ( !image.SaveFile( dir + wxT("test.xpm"), wxBITMAP_TYPE_XPM )) { wxLogError(wxT("Can't save file")); } #endif #if wxUSE_PNM image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_ag.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_asciigrey_pnm = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse_rg.pnm"), wxBITMAP_TYPE_PNM ) ) { wxLogError(wxT("Can't load PNM image")); } else { my_horse_rawgrey_pnm = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tif"), wxBITMAP_TYPE_TIF ) ) { wxLogError(wxT("Can't load TIFF image")); } else { my_horse_tiff = wxBitmap( image ); } #endif #if wxUSE_LIBTIFF image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.tga"), wxBITMAP_TYPE_TGA ) ) { wxLogError(wxT("Can't load TGA image")); } else { my_horse_tga = wxBitmap( image ); } #endif CreateAntiAliasedBitmap(); my_smile_xbm = wxBitmap( (const char*)smile_bits, smile_width, smile_height, 1 ); // demonstrates XPM automatically using the mask when saving if ( m_bmpSmileXpm.Ok() ) m_bmpSmileXpm.SaveFile(wxT("saved.xpm"), wxBITMAP_TYPE_XPM); #if wxUSE_ICO_CUR image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 0 ) ) { wxLogError(wxT("Can't load first ICO image")); } else { my_horse_ico32 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 1 ) ) { wxLogError(wxT("Can't load second ICO image")); } else { my_horse_ico16 = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.ico") ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_ico = wxBitmap( image ); } image.Destroy(); if ( !image.LoadFile( dir + wxT("horse.cur"), wxBITMAP_TYPE_CUR ) ) { wxLogError(wxT("Can't load best ICO image")); } else { my_horse_cur = wxBitmap( image ); xH = 30 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X) ; yH = 2420 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y) ; } m_ani_images = wxImage::GetImageCount ( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI ); if (m_ani_images==0) { wxLogError(wxT("No ANI-format images found")); } else { my_horse_ani = new wxBitmap [m_ani_images]; } int i; for (i=0; i < m_ani_images; i++) { image.Destroy(); if (!image.LoadFile( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI, i )) { wxString tmp = wxT("Can't load image number "); tmp << i ; wxLogError(tmp); } else my_horse_ani [i] = wxBitmap( image ); } #endif // wxUSE_ICO_CUR image.Destroy(); // test image loading from stream wxFile file(dir + wxT("horse.bmp")); if ( file.IsOpened() ) { wxFileOffset len = file.Length(); size_t dataSize = (size_t)len; void *data = malloc(dataSize); if ( file.Read(data, dataSize) != len ) { wxLogError(wxT("Reading bitmap file failed")); } else { wxMemoryInputStream mis(data, dataSize); if ( !image.LoadFile(mis) ) { wxLogError(wxT("Can't load BMP image from stream")); } else { my_horse_bmp2 = wxBitmap( image ); } } free(data); } }
void DIALOG_COLOR_CONFIG::CreateControls() { wxButton* button; wxStaticText* label; int buttonId = 1800; BUTTONINDEX* groups = buttonGroups; m_outerBoxSizer = new wxBoxSizer( wxVERTICAL ); SetSizer( m_outerBoxSizer ); m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); m_outerBoxSizer->Add( m_mainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 ); while( groups->m_Buttons != NULL ) { COLORBUTTON* buttons = groups->m_Buttons; m_columnBoxSizer = new wxBoxSizer( wxVERTICAL ); m_mainBoxSizer->Add( m_columnBoxSizer, 1, wxALIGN_TOP | wxLEFT | wxTOP, 5 ); m_rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); m_columnBoxSizer->Add( m_rowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); // Add a text string to identify the column of color select buttons. label = new wxStaticText( this, wxID_ANY, groups->m_Name ); // Make the column label font bold. wxFont font( label->GetFont() ); font.SetWeight( wxFONTWEIGHT_BOLD ); label->SetFont( font ); m_rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); while( buttons->m_Layer >= 0 ) { m_rowBoxSizer = new wxBoxSizer( wxHORIZONTAL ); m_columnBoxSizer->Add( m_rowBoxSizer, 0, wxGROW | wxALL, 0 ); wxMemoryDC iconDC; wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( bitmap ); EDA_COLOR_T color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) ); currentColors[ buttons->m_Layer ] = color; iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; ColorSetBrush( &brush, color ); #if wxCHECK_VERSION( 3, 0, 0 ) brush.SetStyle( wxBRUSHSTYLE_SOLID ); #else brush.SetStyle( wxSOLID ); #endif iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); m_bitmapButton = new wxBitmapButton( this, buttonId, bitmap, wxDefaultPosition, wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) ); m_bitmapButton->SetClientData( (void*) buttons ); m_rowBoxSizer->Add( m_bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) ); m_rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 ); buttonId += 1; buttons++; } groups++; } Connect( 1800, buttonId - 1, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG::SetColor ) ); // Add a spacer to improve appearance. m_columnBoxSizer->AddSpacer( 5 ); wxArrayString m_SelBgColorStrings; m_SelBgColorStrings.Add( _( "White" ) ); m_SelBgColorStrings.Add( _( "Black" ) ); m_SelBgColor = new wxRadioBox( this, wxID_ANY, _( "Background Color" ), wxDefaultPosition, wxDefaultSize, m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS ); m_SelBgColor->SetSelection( ( m_parent->GetDrawBgColor() == BLACK ) ? 1 : 0 ); m_columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 ); currentColors[ LAYER_BACKGROUND ] = m_parent->GetDrawBgColor(); // Provide a line to separate all of the controls added so far from the // "OK", "Cancel", and "Apply" buttons (which will be added after that // line). m_line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_outerBoxSizer->Add( m_line, 0, wxGROW | wxALL, 5 ); // Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply // buttons; using that type of sizer results in those buttons being // automatically located in positions appropriate for each (OS) version of // KiCad. m_stdDialogButtonSizer = new wxStdDialogButtonSizer; m_outerBoxSizer->Add( m_stdDialogButtonSizer, 0, wxGROW | wxALL, 10 ); button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 ); m_stdDialogButtonSizer->AddButton( button ); button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); m_stdDialogButtonSizer->AddButton( button ); button->SetFocus(); button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition, wxDefaultSize, 0 ); m_stdDialogButtonSizer->AddButton( button ); Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG::OnOkClick ) ); Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG::OnCancelClick ) ); Connect( wxID_APPLY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG::OnApplyClick ) ); m_stdDialogButtonSizer->Realize(); // Dialog now needs to be resized, but the associated command is found elsewhere. }
/* Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard */ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) { wxFileName fn( Parent()->GetDefaultFileName() ); wxString FullFileName; wxString file_ext, mask; bool fmt_is_jpeg = false; if( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) fmt_is_jpeg = true; if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); mask = wxT( "*." ) + file_ext; FullFileName = Parent()->GetDefaultFileName(); fn.SetExt( file_ext ); FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString, fn.GetFullName(), file_ext, mask, this, wxFD_SAVE, true ); if( FullFileName.IsEmpty() ) return; // Be sure the screen area destroyed by the file dialog is redrawn before making // a screen copy. // Without this call, under Linux the screen refresh is made to late. wxYield(); } struct vieport_params { GLint originx; GLint originy; GLint x; GLint y; } viewport; // Build image from the 3D buffer wxWindowUpdateLocker noUpdates( this ); glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport ); unsigned char* pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 ); unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y ); wxImage image( viewport.x, viewport.y ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadBuffer( GL_BACK_LEFT ); glReadPixels( viewport.originx, viewport.originy, viewport.x, viewport.y, GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer ); glReadPixels( viewport.originx, viewport.originy, viewport.x, viewport.y, GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer ); image.SetData( pixelbuffer ); image.SetAlpha( alphabuffer ); image = image.Mirror( false ); wxBitmap bitmap( image ); if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { wxBitmapDataObject* dobjBmp = new wxBitmapDataObject; dobjBmp->SetBitmap( bitmap ); if( wxTheClipboard->Open() ) { if( !wxTheClipboard->SetData( dobjBmp ) ) wxMessageBox( _( "Failed to copy image to clipboard" ) ); wxTheClipboard->Flush(); /* the data in clipboard will stay * available after the * application exits */ wxTheClipboard->Close(); } } else { wxImage image = bitmap.ConvertToImage(); if( !image.SaveFile( FullFileName, fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) ) wxMessageBox( _( "Can't save file" ) ); image.Destroy(); } }
wxBitmap CProjectProcessingPage::GetBitmapResource( const wxString& name ) { // Bitmap retrieval if (name == wxT("res/wizprogress01.xpm")) { wxBitmap bitmap(wizprogress01_xpm); return bitmap; } else if (name == wxT("res/wizprogress02.xpm")) { wxBitmap bitmap(wizprogress02_xpm); return bitmap; } else if (name == wxT("res/wizprogress03.xpm")) { wxBitmap bitmap(wizprogress03_xpm); return bitmap; } else if (name == wxT("res/wizprogress04.xpm")) { wxBitmap bitmap(wizprogress04_xpm); return bitmap; } else if (name == wxT("res/wizprogress05.xpm")) { wxBitmap bitmap(wizprogress05_xpm); return bitmap; } else if (name == wxT("res/wizprogress06.xpm")) { wxBitmap bitmap(wizprogress06_xpm); return bitmap; } else if (name == wxT("res/wizprogress07.xpm")) { wxBitmap bitmap(wizprogress07_xpm); return bitmap; } else if (name == wxT("res/wizprogress08.xpm")) { wxBitmap bitmap(wizprogress08_xpm); return bitmap; } else if (name == wxT("res/wizprogress09.xpm")) { wxBitmap bitmap(wizprogress09_xpm); return bitmap; } else if (name == wxT("res/wizprogress10.xpm")) { wxBitmap bitmap(wizprogress10_xpm); return bitmap; } else if (name == wxT("res/wizprogress11.xpm")) { wxBitmap bitmap(wizprogress11_xpm); return bitmap; } else if (name == wxT("res/wizprogress12.xpm")) { wxBitmap bitmap(wizprogress12_xpm); return bitmap; } return wxNullBitmap; }
wxBitmap rigoMainFrame::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin rigoMainFrame bitmap retrieval if (name == wxT("Art\\page_attach.png")) { wxBitmap bitmap(_T("Art\\page_attach.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\disk.png")) { wxBitmap bitmap(_T("Art\\disk.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\door_in.png")) { wxBitmap bitmap(_T("Art\\door_in.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\cut_red.png")) { wxBitmap bitmap(_T("Art\\cut_red.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\page_refresh.png")) { wxBitmap bitmap(_T("Art\\page_refresh.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\user_edit.png")) { wxBitmap bitmap(_T("Art\\user_edit.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\wrench_orange.png")) { wxBitmap bitmap(_T("Art\\wrench_orange.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\book_edit.png")) { wxBitmap bitmap(_T("Art\\book_edit.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\comment_add.png")) { wxBitmap bitmap(_T("Art\\comment_add.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\email_add.png")) { wxBitmap bitmap(_T("Art\\email_add.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\folder_page_white.png")) { wxBitmap bitmap(_T("Art\\folder_page_white.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\printer.png")) { wxBitmap bitmap(_T("Art\\printer.png"), wxBITMAP_TYPE_PNG); return bitmap; } else if (name == wxT("Art\\page_edit.png")) { wxBitmap bitmap(_T("Art\\page_edit.png"), wxBITMAP_TYPE_PNG); return bitmap; } return wxNullBitmap; ////@end rigoMainFrame bitmap retrieval }
void SIM_PLOT_FRAME::updateSignalList() { SIM_PLOT_PANEL* plotPanel = CurrentPlot(); if( !plotPanel ) return; m_signals->ClearAll(); wxSize size = m_signals->GetClientSize(); m_signals->AppendColumn( _( "Signal" ), wxLIST_FORMAT_LEFT, size.x ); // Build an image list, to show the color of the corresponding trace // in the plot panel // This image list is used for trace and cursor lists wxMemoryDC bmDC; const int isize = bmDC.GetCharHeight(); if( m_signalsIconColorList == NULL ) m_signalsIconColorList = new wxImageList( isize, isize, false ); else m_signalsIconColorList->RemoveAll(); for( const auto& trace : CurrentPlot()->GetTraces() ) { wxBitmap bitmap( isize, isize ); bmDC.SelectObject( bitmap ); wxColor tcolor = trace.second->GetTraceColour(); wxColour bgColor = m_signals->wxWindow::GetBackgroundColour(); bmDC.SetPen( wxPen( bgColor ) ); bmDC.SetBrush( wxBrush( bgColor ) ); bmDC.DrawRectangle( 0, 0, isize, isize ); // because bmDC.Clear() does not work in wxGTK bmDC.SetPen( wxPen( tcolor ) ); bmDC.SetBrush( wxBrush( tcolor ) ); bmDC.DrawRectangle( 0, isize / 4 + 1, isize, isize / 2 ); bmDC.SelectObject( wxNullBitmap ); // Needed to initialize bitmap bitmap.SetMask( new wxMask( bitmap, *wxBLACK ) ); m_signalsIconColorList->Add( bitmap ); } if( bmDC.IsOk() ) { bmDC.SetBrush( wxNullBrush ); bmDC.SetPen( wxNullPen ); } m_signals->SetImageList( m_signalsIconColorList, wxIMAGE_LIST_SMALL ); // Fill the signals listctrl. Keep the order of names and // the order of icon color identical, because the icons // are also used in cursor list, and the color index is // calculated from the trace name index int imgidx = 0; for( const auto& trace : m_plots[plotPanel].m_traces ) { m_signals->InsertItem( imgidx, trace.first, imgidx ); imgidx++; } }
void rigoMainFrame::CreateControls() { ////@begin rigoMainFrame content construction // Generated by DialogBlocks, 07/18/06 21:14:36 (Personal Edition) rigoMainFrame* itemFrame1 = this; wxMenuBar* menuBar = new wxMenuBar; wxMenu* itemMenu3 = new wxMenu; { wxMenuItem* menuItem = new wxMenuItem(itemMenu3, New, _("New"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\page_attach.png"))); menuItem->SetBitmap(bitmap); itemMenu3->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu3, Save, _("Save"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\disk.png"))); menuItem->SetBitmap(bitmap); itemMenu3->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu3, Quit, _("Quit"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\door_in.png"))); menuItem->SetBitmap(bitmap); itemMenu3->Append(menuItem); } menuBar->Append(itemMenu3, _("File")); wxMenu* itemMenu7 = new wxMenu; { wxMenuItem* menuItem = new wxMenuItem(itemMenu7, Cut, _("Cut"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\cut_red.png"))); menuItem->SetBitmap(bitmap); itemMenu7->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu7, Copy, _("Copy"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\page_refresh.png"))); menuItem->SetBitmap(bitmap); itemMenu7->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu7, Profile, _("Profile"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\user_edit.png"))); menuItem->SetBitmap(bitmap); itemMenu7->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu7, Export, _("Export"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\wrench_orange.png"))); menuItem->SetBitmap(bitmap); itemMenu7->Append(menuItem); } menuBar->Append(itemMenu7, _("&Edit")); wxMenu* itemMenu12 = new wxMenu; { wxMenuItem* menuItem = new wxMenuItem(itemMenu12, NewSource, _("New Source"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\book_edit.png"))); menuItem->SetBitmap(bitmap); itemMenu12->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu12, NewQuote, _("Add Quotation"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\comment_add.png"))); menuItem->SetBitmap(bitmap); itemMenu12->Append(menuItem); } { wxMenuItem* menuItem = new wxMenuItem(itemMenu12, NewAnnotation, _("Add Annotation"), _T(""), wxITEM_NORMAL); wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("Art\\email_add.png"))); menuItem->SetBitmap(bitmap); itemMenu12->Append(menuItem); } menuBar->Append(itemMenu12, _("Tools")); itemFrame1->SetMenuBar(menuBar); wxToolBar* itemToolBar16 = CreateToolBar( wxTB_FLAT|wxTB_HORIZONTAL, Rigo_Toolbar ); itemToolBar16->SetMargins(5, 1); itemToolBar16->SetToolBitmapSize(wxSize(16, 16)); wxBitmap itemtool17Bitmap(itemFrame1->GetBitmapResource(wxT("Art\\folder_page_white.png"))); itemToolBar16->AddTool(Open, _T(""), itemtool17Bitmap, _("Open"), wxITEM_NORMAL); wxBitmap itemtool18Bitmap(itemFrame1->GetBitmapResource(wxT("Art\\wrench_orange.png"))); itemToolBar16->AddTool(Export, _T(""), itemtool18Bitmap, _("Export"), wxITEM_NORMAL); wxBitmap itemtool19Bitmap(itemFrame1->GetBitmapResource(wxT("Art\\printer.png"))); itemToolBar16->AddTool(Print, _T(""), itemtool19Bitmap, _("Print"), wxITEM_NORMAL); wxBitmap itemtool20Bitmap(itemFrame1->GetBitmapResource(wxT("Art\\disk.png"))); itemToolBar16->AddTool(Save, _T(""), itemtool20Bitmap, _("Save"), wxITEM_NORMAL); itemToolBar16->AddSeparator(); wxBitmap itemtool22Bitmap(itemFrame1->GetBitmapResource(wxT("Art\\page_edit.png"))); itemToolBar16->AddTool(Writebiblo, _T(""), itemtool22Bitmap, _("Biblography"), wxITEM_NORMAL); /*wxString itemComboBox23Strings[] = { "Source2", "Source 3" };*/ sourceList.Add(wxT("No Sources")); wxComboBox* itemComboBox23 = new wxComboBox( itemToolBar16, ID_COMBOBOX, wxT("No Sources"), wxDefaultPosition, wxDefaultSize, sourceList, wxCB_DROPDOWN); //wxComboBox* itemComboBox23 = new wxComboBox( itemToolBar16, ID_COMBOBOX, "Source1", wxDefaultPosition, wxDefaultSize, 2, itemComboBox23Strings, wxCB_DROPDOWN ); //itemComboBox23->SetStringSelection("Source1"); itemToolBar16->AddControl(itemComboBox23); itemToolBar16->Realize(); itemFrame1->SetToolBar(itemToolBar16); wxPanel* itemPanel24 = new wxPanel( itemFrame1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); wxGridSizer* itemGridSizer25 = new wxGridSizer(1, 1, 0, 0); itemPanel24->SetSizer(itemGridSizer25); wxNotebook* itemNotebook26 = new wxNotebook( itemPanel24, ID_NOTEBOOK, wxDefaultPosition, wxSize(100, 100), wxNB_TOP ); itemGridSizer25->Add(itemNotebook26, 0, wxGROW|wxGROW|wxALL, 0); wxStatusBar* itemStatusBar27 = new wxStatusBar( itemFrame1, ID_STATUSBAR, wxST_SIZEGRIP|wxNO_BORDER ); itemStatusBar27->SetFieldsCount(2); itemFrame1->SetStatusBar(itemStatusBar27); ////@end rigoMainFrame content construction }