mayo icon indicating copy to clipboard operation
mayo copied to clipboard

Export to image using active camera orientation and transparent background

Open virtualdj opened this issue 1 year ago • 5 comments

I would like the Image output feature of File > Export selected items to obey the current camera view in the UI, if possible. It would be great to have also a transparent background option when using formats that support it (such as PNG).

The Save View to image feature is not the same, because it also outputs the grid and controls.

Thanks for this wonderful piece of software! 😎

virtualdj avatar Aug 04 '24 12:08 virtualdj

Unfortunately, to my knowledge OpenCascade 3D view doesn't support transparent background

HuguesDelorme avatar Aug 06 '24 16:08 HuguesDelorme

OK, what a pity, it could have been useful to integrate into other apps... anyway, at least saving with same orientation could be enough 😃

virtualdj avatar Aug 06 '24 18:08 virtualdj

Unfortunately, to my knowledge OpenCascade 3D view doesn't support transparent background

Hi, sorry if I reply again, but I found this question on the OpenCascade forums. I'm not really a C++ expert (actually I'm not a programmer at all), but could it be that changing this: https://github.com/fougue/mayo/blob/3b4d7e6f67f6c49a0a777a6eaa00a2f21998d0e5/src/io_image/io_image.cpp#L191

to Graphic3d_BT_RGBA and providing the alpha component might work with PNG?

virtualdj avatar Aug 06 '24 20:08 virtualdj

I tried this but couldn't make it work:

  • create a transparent PNG file
  • call V3d_View::SetBackgroundImage() with this PNG file(within ImageWriter::createV3dView() function)
  • set dumpOptions.BufferType = Graphic3d_BT_RGBA;(within ImageWriter::createV3dView() function)
  • set pixmap->SetFormat(Image_Format_RGBA);(within ImageWriter::createV3dView() function)
  • map QImage::Format_RGBA8888 to Image_Format_RGBA in function toQPixmap()(within qtgui_utils.cpp file)

The problem certainly lies with V3d_View not supporting transparent background(no alpha color channel)

HuguesDelorme avatar Aug 07 '24 14:08 HuguesDelorme

  • create a transparent PNG file
  • call V3d_View::SetBackgroundImage() with this PNG file(within ImageWriter::createV3dView() function)

Why is it necessary to use SetBackgroundImage()? I would like the created image to be transparent, not to add a transparent image as a background. But I see now that V3d_View::SetBackgroundColor() doesn't have options for RGBA 😢 so probably we're in trouble.

virtualdj avatar Aug 07 '24 16:08 virtualdj