Problème avec la fonction GdiTransparentBlt

Résolu
blackcatthc Messages postés 86 Date d'inscription jeudi 4 mars 2004 Statut Membre Dernière intervention 1 avril 2015 - 19 janv. 2007 à 00:01
blackcatthc Messages postés 86 Date d'inscription jeudi 4 mars 2004 Statut Membre Dernière intervention 1 avril 2015 - 19 janv. 2007 à 21:57
Slt

j'utilse la fonction GdiTransparentBlt  pour afficher des  images venant d'une picturebox1 dans une  picturebox2. Pour pouvoir profité de la couleur transparent de l'image.

 le problème c'est que l'image que j'affiche dans la picturebox2 disparait dans le cas ou je fait passé une fenètre  de windows par exemple ou  encore si je déplace la fenètre de mon projet hors de l'écran. y a t'il un moyen de figer cette image pour évite ce genre de problème.

6 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
19 janv. 2007 à 20:52
ouais, enfin, pour le coup de la fenere qui survolle la picturebox et qui provoque la perte partielle de l'image, c'est l'AutoRedraw de la PictureBox qui est en cause.......

Renfield
Admin CodeS-SourceS- MVP Visual Basic
3
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
19 janv. 2007 à 06:24
Change ta propriété AutoRedraw

Renfield
Admin CodeS-SourceS- MVP Visual Basic
0
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
19 janv. 2007 à 07:56
Bonjour,

Non,

GdiTransparentBlt fait une superposition "en image"...., sans modifier la propriété picture de la picturebox de destination.


 
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
19 janv. 2007 à 12:09
Salut,


Y aun source qu'a l'air très sympa de EBartSoft pour ce qui est de gestion d'images avec transparence.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
zavier666 Messages postés 266 Date d'inscription mardi 7 septembre 2004 Statut Membre Dernière intervention 30 avril 2009 1
19 janv. 2007 à 16:39
Il exsite un moyen d'utiliser les fichier type "png/gif"


Let's go:

 I) Déclaration des fonctions

Cette première étape
consiste à déclarer l'ensemble des fonctions qui seront
utilisées.

Private Declare Function GdipCreateFromHDC Lib "gdiplus" (
_
ByVal hdc As Long, graphics As Long) As GpStatus
Private Declare
Function GdipDisposeImage Lib "gdiplus" ( _
ByVal image As Long) As
GpStatus
Private Declare Function GdipDrawImageRectRectI Lib "gdiplus" (
_
ByVal graphics As Long, ByVal image As Long, ByVal dstx As Long, _
ByVal
dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long,_
ByVal srcx As
Long, ByVal srcy As Long, ByVal srcwidth As Long, _
ByVal srcheight As Long,
ByVal srcUnit As GpUnit, _
ByVal imageAttributes As Long, Optional ByVal
callback As Long = 0, _
Optional ByVal callbackData As Long = 0) As
GpStatus
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (
_
ByVal graphics As Long) As GpStatus
Private Declare Function
GdipLoadImageFromFile Lib "gdiplus" ( _
ByVal filename As String, ByRef image
As Long) As GpStatus
Private Declare Function GdiplusStartup Lib "gdiplus" (
_
ByRef token As Long, inputbuf As GdiplusStartupInput, Optional ByVal
outputbuf As Long = 0) As GpStatus
Private Declare Sub GdiplusShutdown Lib
"gdiplus" ( _
ByVal token As Long)

II) Déclaration des
types de données personnalisés

Cette deuxième étape consiste à
déclarer les types de données personnalisées utilisés par les fonctions

Private Enum GpStatus
Gp_Ok = 0
Gp_GenericError =
1
Gp_InvalidParameter = 2
Gp_OutOfMemory = 3
Gp_ObjectBusy =
4
Gp_InsufficientBuffer = 5
Gp_NotImplemented = 6
Gp_Win32Error =
7
Gp_WrongState = 8
Gp_Aborted = 9
Gp_FileNotFound =
10
Gp_ValueOverflow = 11
Gp_AccessDenied = 12
Gp_UnknownImageFormat =
13
Gp_FontFamilyNotFound = 14
Gp_FontStyleNotFound =
15
Gp_NotTrueTypeFont = 16
Gp_UnsupportedGdiplusVersion =
17
Gp_GdiplusNotInitialized = 18
Gp_PropertyNotFound =
19
Gp_PropertyNotSupported = 20
End Enum

Private Type
GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As
Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As
Long
End Type

Private Enum GpUnit
UnitWorld = 0
UnitDisplay =
1
UnitPixel = 2
UnitPoint = 3
UnitInch = 4
UnitDocument =
5
UnitMillimeter = 6
End Enum

III) Lancement de
l'image

Private Sub Form_MouseDown(Button As Integer, Shift
As Integer, x As Single, y As Single)
Dim handle_graph As Long
Dim
handle_image As Long
Dim handle_imageAttr As Long
Dim param As
GdiplusStartupInput
Dim handle_session_gdiplus As Long
'
On allume GDIplus
' Si on n'active/désactive pas GDI+ comme il faut, quand il
faut, vous allez faire crasher votre VB.
param.GdiplusVersion =
1
GdiplusStartup handle_session_gdiplus, param

If
GdipCreateFromHDC(Me.hdc, handle_graph) = Gp_Ok Then
'
Chargement de l'image (PNG/JPG/TIF/GIF/BMP...)
fichier = App.Path +
"/param.png"
MsgBox fichier
If GdipLoadImageFromFile(StrConv(fichier,
vbUnicode), handle_image) = Gp_Ok Then
' On dessine
l'image.
GdipDrawImageRectRectI handle_graph, handle_image, x, y, 128,
128, 0, 0, 128, 128, UnitPixel, 0
End If

' On libère
l'image
GdipDisposeImage handle_image
End If

' On détruit notre objet Graphic
GdipDeleteGraphics
handle_graph

GdiplusShutdown
handle_session_gdiplus

Me.Refresh
End Sub


slts!

___________________________________________________________

Toutes les explications sur GDIplus et toujours + d'APi => API  @ la Loupe

http://xav.prog.power.free.fr
0
blackcatthc Messages postés 86 Date d'inscription jeudi 4 mars 2004 Statut Membre Dernière intervention 1 avril 2015
19 janv. 2007 à 21:57
Oui c'etait bien ca. merci .
0
Rejoignez-nous