![]() Set the SourceConstantAlpha value to 255 (which indicates that the image is opaque) when you only want to use per-pixel alpha values. If SourceConstantAlpha is 0, it is assumed that the image is transparent. The SourceConstantAlpha value is combined with any per-pixel alpha values. It loads an image with transparent parts, uses this image to set the shape of the window and draws the image on the window. The SourceConstantAlpha member of BLENDFUNCTION specifies an alpha transparency value to be used on the entire source bitmap. This repository contains an example of how to create non-rectangular semi-transparent windows on multiple operating systems with SFML (which is only used to load the image and display the result). The source rectangle must lie completely within the source surface, otherwise an error occurs and the function returns FALSE.ĪlphaBlend fails if the width or height of the source or destination is negative. If the source and destination are the same surface, that is, they are both the screen or the same memory bitmap and the source and destination rectangles overlap, an error occurs and the function returns FALSE. Note that, for a display DC, all blending operations are supported and these flags represent whether the operations are accelerated. When rendering to a printer, first call GetDeviceCaps with SHADEBLENDCAPS to determine if the printer supports blending with AlphaBlend. If either the width or height of the source or destination is negative, this call will fail. If destination and source bitmaps do not have the same color format, AlphaBlend converts the source bitmap to match the destination bitmap.ĪlphaBlend does not support mirroring. ![]() The source coordinates are transformed by using the transformation currently specified for the source device context.Īn error occurs (and the function returns FALSE) if the source device context identifies an enhanced metafile device context. The destination coordinates are transformed by using the transformation currently specified for the destination device context. If the SetStretchBltMode function is used, the iStretchMode value is automatically converted to COLORONCOLOR for this function (that is, BLACKONWHITE, WHITEONBLACK, and HALFTONE are changed to COLORONCOLOR). If the source rectangle and destination rectangle are not the same size, the source bitmap is stretched to match the destination rectangle. If the function fails, the return value is FALSE. If the function succeeds, the return value is TRUE. See the BLENDFUNCTION and EMRALPHABLEND structures. The source and destination blend functions are currently limited to AC_SRC_OVER. The alpha-blending function for source and destination bitmaps, a global alpha value to be applied to the entire source bitmap, and format information for the source bitmap. The height, in logical units, of the source rectangle. The width, in logical units, of the source rectangle. The y-coordinate, in logical units, of the upper-left corner of the source rectangle. The x-coordinate, in logical units, of the upper-left corner of the source rectangle. ![]() The height, in logical units, of the destination rectangle. The width, in logical units, of the destination rectangle. The y-coordinate, in logical units, of the upper-left corner of the destination rectangle. The x-coordinate, in logical units, of the upper-left corner of the destination rectangle. Syntax BOOL AlphaBlend(Ī handle to the destination device context. Also you would want to use double buffering here so that things get drawn on the screen smoothly.The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels. When you no longer need the rectangle then you can simply set it 0,0,0,0 and nothing will be drawn. You will have to keep track of the rectangle coordinates and when WM_PAINT is sent then draw the bitmap followed by the rectangle. CPaintDC dc(this) CDC MemDC MemDC.CreateCompatibleDC(&dc) CBitmap *pOldBmp = MemDC.SelectObject(&m_Bitmap) MemDC.Rectanlge(StartX, StartY, EndX, EndY) MemDC.SelectObject(pOldBmp) If the rectangle is eraseable, then you will have to do some fancy footwork. If the rectangle is permanent, which means that you don't want to erase it at a later time, then you can simply draw it on the bitmap itself, and update the window which calls your WM_PAINT stuff, and the bitmap with the new drawing will get painted on the screen. You have 2 options, which one you choose depends on what you are trying to achieve. The problem is that you are doing your drawing in mouse event handlers, and once that is done your WM_PAINT stuff gets called and redraws the original bitmap on the screen which erases everything you did in your mouse handlers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |