Accueil > Forum > > > > centrer image dans picture Box ? au secours
centrer image dans picture Box ? au secours
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ée dans : image, box, écran, picture, centrer
Répondre à ce message
Livres en rapport
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
Comparez les prix

HTC Hero
Entre 550€ et 550€
|