begin process at 2010 02 09 19:40:03
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Visual Basic & VB.NET

 > 

Archives Visual Basic

 > 

Graphique

 > 

centrer image dans picture Box ? au secours


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

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

Administrateur CodeS-SourceS
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

Administrateur CodeS-SourceS
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

Administrateur CodeS-SourceS
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

Sujets en rapport avec ce message

Picture Box [ par Pierre ] BonjourJe suis débutant en programmation avec Visual Basic, je n'ai aucune formation en programmationJ'avais une revue ou il y avait un petit programm Deplacement d'une image dans un picture box a l'aide de scrollbar [ par Bap ] Deplacement d'une image dans un picture box a l'aide de scrollbarVoila mon problemme si qlq sait faire ou a une piste je veux bienmerci.. comment imprimer une picture box avec des image.picture a l'interieur [ par toto ] comment imprimer une picture box avec des image.picture a l'interieurmerci comment imprimer une picture box avec des image.picture a l'interieur [ par toto ] comment imprimer une picture box avec des image.picture a l'interieurmerci comment imprimer une picture box avec des image.picture a l'interieur [ par toto ] comment imprimer une picture box avec des image.picture a l'interieurmerci rotation d'image dans un picture Box [ par tintin ] La question a déja été posée, mais aucune réponse efficace n'a été donnée. C'est pourquoi je me permet de reposer la question.J'ai essayer la solution ????? Comment récupérer la partie visible d'une image dans un picture box ?????? [ par tnt ] Salut j'ai un p'tit problème je charge une image dans un picture box et l'image est plus grande que le picture box.J'aimerais savoir comment recupérer au secour aidez-moi!!!! [ par tnt ] Salut j'ai un p'tit problème et ca fait 3 fois que je poste ma question! Donner moi des idées n'importe quoi! je charge une image dans un picture box Centrer une picture dans une MDIform ? [ par caroline ] Bonjour à tous !Dans une MDIform, on peut charger une image de fond dans la feuille grâce à la propriété "Picture", c'est très bien, mais, cette image


Nos sponsors


Sondage...

Comparez les prix


HTC Hero

Entre 550€ et 550€

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,577 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales