[vtkusers] Transparency
BERT Sylvain
bert at esigetel.fr
Fri Feb 14 03:53:27 EST 2003
Hi Dave, thanks for your answer.
But, indeed, what i want, is the background to be transparent (and not
the sphere) because i have a video stream behind this sphere.
I have obtained the handle of the vtkwindow (=renWin) by the followng code:
HWND hwnd = renWin->GetWindowId();
Then, i use this hwnd in a function called MakeAlpha() you can see after.
typedef BOOL (WINAPI *SLWA_FUNC)(HWND hwnd,COLORREF crKey,BYTE
bAlpha,DWORD dwFlags);
BOOL MakeAlpha(HWND hwnd,BYTE alpha)
{
// Récupération ddu handle de User32.dll, puis de l'adresse de
// la fonction SetLayeredWindowAttributes dans cette Dll.
SLWA_FUNC MySetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle("USER32.DLL");
if (!hUser32) return FALSE;
MySetLayeredWindowAttributes =
(SLWA_FUNC)GetProcAddress(hUser32,"SetLayeredWindowAttributes");
if (MySetLayeredWindowAttributes)
{
MySetLayeredWindowAttributes(hwnd,0x00FFFFFF,NULL,LWA_COLORKEY);
// => toutes les parties blanches seront transparentes
// Le reste sera normal
return TRUE;
} else {
// Si pas Windows 2000 ou Windows XP, la fonction
SetLayeredWindowAttributes
// n'existe pas, il est donc impossible d'appliquer le paramètre.
MessageBox(hwnd,"Impossible de passer la fenêtre en
WS_EX_LAYERED","Erreur",MB_ICONERROR);
return FALSE;
}
}
The above function is used by the program but nothing happens. Do i have
to use an update() function ?
Moreover, i have already used SetOpacity() but it works only on the vtk
object (sphere) and not on the background.
If you have a idea about this, please let me know.
Thanks a lot.
Sylvain
David.Pont at ForestResearch.co.nz a écrit:
>Hi Sylvian,
> Do you want to make the sphere transparent, so you will see the
>background through it? Take a look at vtkActor->GetProperty()-SetOpacity.
>Dave Pont
>
>
>|--------+--------------------------------->
>| | BERT Sylvain |
>| | <bert at esigetel.fr> |
>| | Sent by: |
>| | vtkusers-admin at public.k|
>| | itware.com |
>| | |
>| | |
>| | 14/02/2003 00:23 |
>| | Please respond to bert |
>| | |
>|--------+--------------------------------->
> >------------------------------------------------------------------------------------------------------------|
> | |
> | To: vtkusers at public.kitware.com |
> | cc: |
> | Subject: [vtkusers] Transparency |
> >------------------------------------------------------------------------------------------------------------|
>
>
>
>
>Hi all, i have the following vtk code which is very simple. It's a red
>Sphere on a white background.
>Does anyone know what can i do to have the background transparent ? (The
>transparency works only with W2000 et XP).
>It's very important for me.
>Thanks a lot !
>
>Sylvain
>
>
>#include "vtkSphereSource.h"
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderer.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkWin32OpenGLRenderWindow.h"
>#include "windows.h"
>#include "winuser.h"
>
>
>void main ()
>{
>
> // create sphere geometry
> vtkSphereSource *sphere = vtkSphereSource::New();
> sphere->SetRadius(1.0);
> sphere->SetThetaResolution(18);
> sphere->SetPhiResolution(18);
>
> // map to graphics library
> vtkPolyDataMapper *map = vtkPolyDataMapper::New();
> map->SetInput(sphere->GetOutput());
>
> // actor coordinates geometry, properties, transformation
> vtkActor *aSphere = vtkActor::New();
> aSphere->SetMapper(map);
> aSphere->GetProperty()->SetColor(1,0,0); // sphere color blue
>
> // a renderer and render window
> vtkRenderer *ren1 = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
> //renWin->SetFullScreen(true);
>
> // an interactor
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> // add the actor to the scene
> ren1->AddActor(aSphere);
> ren1->SetBackground(1,1,1); // Background color white
>
> // render an image (lights and cameras are created automatically)
> renWin->Render();
>
> // begin mouse interaction
> iren->Start();
>}
>
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <
>http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>
>
>
>
>
More information about the vtkusers
mailing list