mathieu57100
Messages postés103Date d'inscriptionjeudi 24 juin 2004StatutMembreDernière intervention 9 février 2006
-
6 oct. 2005 à 14:32
SnOOpss
Messages postés571Date d'inscriptionsamedi 3 avril 2004StatutMembreDernière intervention 5 décembre 2013
-
6 oct. 2005 à 18:28
bonjour,
j'aimerai savoir comment faire appraitre une image seulement dans un cercle, la partie de l'image hors du cercle n'apparaitrait pas.
j'ai essayé avec un composant Timage et un Tshape en forme de cercle, mais ca ne donne pas ce que je veux.
merci d'avance pour vos réponses.
mathieu57100
Messages postés103Date d'inscriptionjeudi 24 juin 2004StatutMembreDernière intervention 9 février 2006 6 oct. 2005 à 16:57
merci pour ta réponse, mais je ne peux pas connaitre à l'avance la couleur de la région, car c'est à l'utiisateur d'insérer une image, par un bouton du genre 'Parcourir...'
kortin
Messages postés65Date d'inscriptiondimanche 27 juillet 2003StatutMembreDernière intervention21 avril 2006 6 oct. 2005 à 17:13
Bon, on est d'accord sur le fait que ton utilisateur va charger une image rectangle.
Donc, il te suffit de travailler l'image pour ne garder ke le cercle du millieu. Tu laisse le reste disons vert (0,255,0) et tu appliques ton mask. Pour travailler l'image, tu peux utiliser le device context.
SnOOpss
Messages postés571Date d'inscriptionsamedi 3 avril 2004StatutMembreDernière intervention 5 décembre 2013 6 oct. 2005 à 18:28
Tu as un example sur Petzold
cf extrait
The MATTHEW.BMP file referred to in the resource script is a digitized black-and-white photograph of a nephew of mine. It's 200 pixels wide, 320 pixels high, and has 8 bits per pixel. However, BITMASK is written so that this file can be just about anything.
Notice that BITMASK colors its window background with a light gray brush. This is to assure ourselves that we're properly masking the bitmap and not just coloring part of it white.
Let's look at WM_CREATE processing. BITMASK uses the LoadBitmap function to obtain a handle to the original image in the variable hBitmapImag. The GetObject function obtains the bitmap width and height. The bitmap handle is then selected in a memory device context whose handle is hdcMemImag.
Next the program creates a monochrome bitmap the same size as the original image. The handle is stored in hBitmapMask and selected into a memory device context whose handle is hdcMemMask. The mask bitmap is colored with a black background and a white ellipse by using GDI functions on the memory device context:
The SRCAND raster operation performs a bitwise AND operation between the bits of the source (the mask bitmap) and the bits of the destination (the original image). Wherever the mask bitmap is white, the destination is preserved. Wherever the mask bitmap is black, the destination becomes black as well. An elliptical area in the original image is now surrounded by black.
Now let's look at WM_PAINT processing. Both the altered image bitmap and the mask bitmap are selected into memory device contexts. Two BitBlt calls perform the magic. The first does a BitBlt of the mask bitmap on the window:
This uses a raster operation for which there is no name. The logical operation is D & ~S. Recall that the source?the mask bitmap?is a white ellipse (1 bits) surrounded by black (0 bits). The raster operation inverts the source so that it's a black ellipse surrounded by white. The raster operation then performs a bitwise AND of this inverted source with the destination?the surface of the window. When the destination is ANDed with 1 bits, it remains unchanged. When ANDed with 0 bits, the destination becomes black. Thus, this BitBlt operation draws a black ellipse in the window.
The second BitBlt call draws the image bitmap on the window:
The raster operation performs a bitwise OR operation between the source and the destination. The outside of the source bitmap is black, so it leaves the destination unchanged. Within the ellipse, the destination is black, so the image is copied unchanged. The result is shown in Figure 14-18.
A few notes:
You may need a mask that is quite complex?for example, one that blots out the whole background of the original image. You'll probably need to create this manually in a paint program and save it to a file.