|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
Sujet : centrer image dans picture Box ? au secours [ Archives Visual Basic / Graphique ] (neo12)
Informations & options pour cette discussion
lundi 29 juillet 2002 à 12:16:24 |
centrer image dans picture Box ? au secours

neo12
|
Bonjour, te travaille sur une appli "diaporama", pour certaines photos plus petites que l'écran je voudrais centrer celles ci (en utilisant un fond de couleur pour compléter l'espace inoccupé pour l'image. LE problème c'est que j'utilise paintpicture pour faire des effets lors de l'affichage. Paintpicture s'utilise avec un contrôle picturebox... Hors quand vous chargez une image dans picture box (par loadpicture) celle ci est placé automatiquement en haut à gauche. je pourrais utiliser une autre picture box à l'inérieur de la 1er ou un contrôle image, mais paintpicture ne récupère que l'image d'un seul contrôle donc ne récupererai soit le fond de la 1er soit l'image de la seconde. Il faudrait que j'ai tout dans la même pour récuperer la totalité par paint picture. J'ai trouvé qlqs fonctions dans les api type type getDC et createindirectbitmap ou en passant par clipboard, le pb c'est que ces fonctions n'utilisent que des DC existantes (écran, imprimante) et permettent d'attribuer à picture box l'image placée mémoire (provenant de l'écran) en la placant à la position voulu dans une picture box, mais je n'arrive pas à ce que le "memorybuffer" fasse la même chose avec un ficheir et non pas avec le DC de l'écran Est ce que qlq'1 pourrait m'aider
|
|
|
mardi 30 juillet 2002 à 14:41:05 |
Need more info

Renfield
|
du calme garcon , on reprend depuis le debut , explique moi comme a un gosse de 4 ans.
Tu load une image (donc tu intervient via un objet de type 'IPictureDisp') me goures-je ?
Ensuite , tu veux la Blitter ou tu veux (au centre) d'un picture box) exact ??
****************************** Si ton probleme c'est ca , une solution est d'utiliser l'API BitBlt, qui te permet , via le Hdc de tes objets picturebox ou image de faire des copies avec certains effets de mélange, d'addition, d'inversion.....
voila un extrait de doc.....
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
· hdcDest Identifies the destination device context.
· nXDest Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
· nYDest Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
· nWidth Specifies the logical width of the source and destination rectangles.
· nHeight Specifies the logical height of the source and the destination rectangles.
· hdcSrc Identifies the source device context.
· nXSrc Specifies the logical x-coordinate of the upper-left corner of the source rectangle.
· nYSrc Specifies the logical y-coordinate of the upper-left corner of the source rectangle.
· dwRop Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color. The following list shows some common raster operation codes: BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.) DSTINVERT Inverts the destination rectangle. MERGECOPY Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator. MERGEPAINT Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator. NOTSRCCOPY Copies the inverted source rectangle to the destination. NOTSRCERASE Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color. PATCOPY Copies the specified pattern into the destination bitmap. PATINVERT Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator. PATPAINT Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator. SRCAND Combines the colors of the source and destination rectangles by using the Boolean AND operator. SRCCOPY Copies the source rectangle directly to the destination rectangle. SRCERASE Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator. SRCINVERT Combines the colors of the source and destination rectangles by using the Boolean XOR operator. SRCPAINT Combines the colors of the source and destination rectangles by using the Boolean OR operator. WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)
************************** Reponds moi pour que je sache si ca reponds bien a ton probleme ou si j'ai mal saisi le contexte lie a ton cas.
Bye . Renfield.
|
|
|
vendredi 2 août 2002 à 01:10:45 |
Re : Need more info

neo12
|
non, pas tout à fait, j'ai passé toutes les fonctiosn bitblt, stretch blt, ça ne réponds pas à mon attente
(au fait je t'ai envoyé un message totu à l'heur temremrciant sans faire avancer le schmilblick, mais j'avias pas vu cete réponse qui pour le coup est utile)
bon je t'explqiue j'utilsie paintpicture dans une picbox "cible" pour faire de effets de transition entre imges à l'origien placés dans des picturebox source. Ca marche très bien (la nouvelle couvre totalement l'ancienne) que si les 2 images sont de m^me taille, ou que la seconde (celel qui est déssiné par dessus) est plus grande que la 1er..jsuque là tu piges.
Mais..il y a un mais...si mon image dans la picutrebox cible fait 1024x768 et que l'image que je fait entrer par dessus avec un effet fait par exeple 800. par 600..je vais toujorus avoir en fond sur la zone restante l'ancienne image qui est + grande. Mon désir est que dans ce cas l'image entrante grade sa dimension mais soit centrée dans un fond uni ...c'est à dire que mon image entrante aura à gauche et à droite 112 pixels + les 800 = 1024 pour faire les 1024 de l'image cible (ces 112 pixels de chaque coté (et les 84 en haut et et en bas sereaint noires par exemple). ?
faire ca dans une pciture box est faisable par les stretcheblt ou le "clipboard" mais qu'en la dessinant par ce mêms fonctions. hors ces fonctions "plaquent" une image sur le hdc de la picturebox, mais la pciture box n'en prends pas les priorité. si tu utilsie après paintpicture (ou stretchblt) pour récupérer ce résultat centré sur un fond, pour la placer dans uen picutrebox cible pour faire un effet de suppersotion entrante, cele provoque une erreur car il ne trouve pas d'image, la propriété picture est "vide" même si à l'écran on à une image dessus; faut en fait que je trouve une fonction uqi me permette décrire picturebox_source.picture = résultat obtenu par bitblt ou tstretchblt ou getclipboard data...pour pouvoir après récupéer cette nouvelle "image" via uen focntion paint picture mais ça provoque uen erreur :-(
Tu cernes mieux le pb ?
------------------------------- Réponse au message : -------------------------------
du calme garcon , on reprend depuis le debut , explique moi comme a un gosse de 4 ans.
Tu load une image (donc tu intervient via un objet de type 'IPictureDisp') me goures-je ?
Ensuite , tu veux la Blitter ou tu veux (au centre) d'un picture box) exact ??
****************************** Si ton probleme c'est ca , une solution est d'utiliser l'API BitBlt, qui te permet , via le Hdc de tes objets picturebox ou image de faire des copies avec certains effets de mélange, d'addition, d'inversion.....
voila un extrait de doc.....
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
· hdcDest Identifies the destination device context.
· nXDest Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
· nYDest Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
· nWidth Specifies the logical width of the source and destination rectangles.
· nHeight Specifies the logical height of the source and the destination rectangles.
· hdcSrc Identifies the source device context.
· nXSrc Specifies the logical x-coordinate of the upper-left corner of the source rectangle.
· nYSrc Specifies the logical y-coordinate of the upper-left corner of the source rectangle.
· dwRop Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color. The following list shows some common raster operation codes: BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.) DSTINVERT Inverts the destination rectangle. MERGECOPY Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator. MERGEPAINT Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator. NOTSRCCOPY Copies the inverted source rectangle to the destination. NOTSRCERASE Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color. PATCOPY Copies the specified pattern into the destination bitmap. PATINVERT Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator. PATPAINT Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator. SRCAND Combines the colors of the source and destination rectangles by using the Boolean AND operator. SRCCOPY Copies the source rectangle directly to the destination rectangle. SRCERASE Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator. SRCINVERT Combines the colors of the source and destination rectangles by using the Boolean XOR operator. SRCPAINT Combines the colors of the source and destination rectangles by using the Boolean OR operator. WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)
************************** Reponds moi pour que je sache si ca reponds bien a ton probleme ou si j'ai mal saisi le contexte lie a ton cas.
Bye . Renfield.
|
|
|
vendredi 2 août 2002 à 09:30:48 |
Peut etre une solution !

Renfield
|
Si il ne 'garde' pas ton image , c'est peu être juste que la propriété Autoredraw de ton picturebox cible n'est pas mise à True !
Ce que tu peux essayer, c'est d'effacer ton image cible , vers une couleur noire !! , et de blitter ton autre image.
|
|
|
samedi 3 août 2002 à 02:59:53 |
Re : Peut etre une solution !

neo12
|
t'es presque dans le mille ! j'ai trouvé la réposne en épluchant le code du gagnant du dernier concorus ! je me suis aperçu qu'il associer à la proriété picture de son picutrebox "cible" la propriété "image" de la picturebox source...et ça marche (en emttant autoredraw à true avant de placer son image par paintpicutre ou bitblt... le résulat visuel dans la pciturebox soruce est une image avaec un fond uni sur lequel est "collé" l'image aux dimensiosn voulus...et il suffit dnas la picturebox cible, d'appeller la proriété IMAGE de la soruce..et ça ramène bien tout ! mais que c'était con, que c'était con...
faut absolumetn que je place cette astuce dans les soruces, je suppose que je suis pas le 1er à galèrer avec cette histoire.
A+
------------------------------- Réponse au message : -------------------------------
Si il ne 'garde' pas ton image , c'est peu être juste que la propriété Autoredraw de ton picturebox cible n'est pas mise à True !
Ce que tu peux essayer, c'est d'effacer ton image cible , vers une couleur noire !! , et de blitter ton autre image.
|
|
|
lundi 5 août 2002 à 11:11:26 |
Re : Peut etre une solution !

Renfield
|
Ok , bien joue, si tu as besoin d'aide , je pourrais peut-etre te sortir d'une autre galere ou 'c'était con'.
Bye ;-)
Amuses-toi bien
Renfield.
|
|
|
Cette discussion est classé dans : image, box, écran, picture, centrer
Répondre à ce message
Livres en rapport
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

HTC Touch HD
Entre 25€ et 605€
|