Change color of font from a bitmap

unhandled

(F Leon Marquez95) #1

Hello, i have a problem changing the colors of the bitmaps i take from the viewports. Whenever i take a bitmap, i get this image with gray background and the surface or object is gray too. Is there a way to change this colors. I am using Rhino 5. My code is the following.

ON_SimpleArray<CRhinoView*> view_list;
context.m_doc.GetViewList( view_list );
	
CRhinoView* view = RhinoApp().ActiveView();

//shading the object before getting the image
	
  if( 0 == view )
    CRhinoCommand::failure;

	ON::display_mode dm = view->ActiveViewport().DisplayMode();
  if( dm != ON::shaded_display )
  {
    view->ActiveViewport().SetDisplayMode( ON::shaded_display );
	context.m_doc.ViewModified(view);
    view->Redraw();
  }
	///////////////////////////////////////////////////////////////////
	
	CWnd* pMainWnd = CWnd::FromHandle( RhinoApp().MainWnd() );
  if( 0 == pMainWnd )
	  CRhinoCommand::nothing;

  CRhinoGetFileDialog gf;
  gf.SetScriptMode( context.IsInteractive() ? FALSE : TRUE );

BOOL rc = gf.DisplayFileDialog( CRhinoGetFileDialog::save_bitmap_dialog, file_name, pMainWnd );
  if( !rc )
	  CRhinoCommand::cancel;

  ON_wString filename = gf.FileName();
  filename.TrimLeftAndRight();
  if( filename.IsEmpty() )
	  CRhinoCommand::failure;

  if( view )
  {
    CRect rect;
    view->GetClientRect( rect );

    CRhinoDib dib;
    if( dib.CreateDib(rect.Width(), rect.Height(), 24, true) )
    {
      // Set these flags as you wish.
      BOOL bIgnoreHighlights = TRUE;
      BOOL bDrawTitle = FALSE;
      BOOL bDrawConstructionPlane = FALSE;
      BOOL bDrawWorldAxes = FALSE;

      CRhinoObjectIterator it( CRhinoObjectIterator::normal_or_locked_objects,
                               CRhinoObjectIterator::active_and_reference_objects
                               );

      if( view->ActiveViewport().DisplayMode() == ON::wireframe_display )
      {
        context.m_doc.DrawToDC( it, dib, dib.Width(), dib.Height(),
          view->ActiveViewport().View(),
          bIgnoreHighlights,
          bDrawTitle,
          bDrawConstructionPlane,
          bDrawWorldAxes
          );
      }
      else
      {
        context.m_doc.RenderToDC( it, dib, dib.Width(), dib.Height(),
          view->ActiveViewport().View(),
          bIgnoreHighlights,
          bDrawTitle,
          bDrawConstructionPlane,
          bDrawWorldAxes,
          view->ActiveViewport().GhostedShade()
          );
      }

      dib.WriteToFile( filename );
    }
  }

(Dale Fugier) #2

Hi @f.leon.marquez95,

Does the viewport look like the captured image (which is what the code is designed to do)?

ā€“ Dale


(F Leon Marquez95) #3

No, even if I change the background to white for example, I still get a gray background and the same happens for the shadowing of my object. I was trying to read methods to change the color, but even though I cannot achieve this


(Dale Fugier) #4

Keep in mind that CRhinoDoc::RenderToDC captures a rendering. So if you are viewing a a viewport in Shaded display, it will not look the same.

Note, if you want more control, use CRhinoPrintInfo::DrawToSingleDib2.

ā€“ Dale


(F Leon Marquez95) #5

Thank you, but how would I make my code according to this specification? Simply by changing CRhinoDoc::RenderToDC to CRhinoPrintInfo::DrawToSingleDib2?


(Dale Fugier) #6

Hi @f.leon.marquez95,

No, Iā€™m sure there is a little more work to do than that. However, the CRhinoPrintInfo class is well-documented - see rhinoSdkPrintInfo.h for details.

ā€“ Dale


(F Leon Marquez95) #7

Thank you for your answer, I read the documentation for that class but I still dont know very good how to implement this method and take a screen shot from the view. Could you please show me an example of doing this?