AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
Go Back  Xtreme Visual Basic Talk > > > AlphaBlend: how use on non transparent images?


Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2016, 11:46 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default AlphaBlend: how use on non transparent images?


Code:
Public Sub Draw(DestinationHDC As Long, blnTransparent As Boolean, Optional Transparency As Long = 255)
    RaiseEvent BeforeDrawImage(intSelectedFrame)
    Dim AO As AlphaOptions
    Dim PointerAlpha As Long
    If (blnTransparent = True) Then
        Dim btMap As BITMAP
        If (GetObject(ImageBitmap, Len(btMap), btMap) = 0) Then Debug.Print "error"
        Dim s As BITMAPINFO
        Dim BytesPerScanLine As Long
        s.bmiHeader.biSize = 40
        s.bmiHeader.biPlanes = 1
        s.bmiHeader.biBitCount = 24
        s.bmiHeader.biHeight = -lngheight
        s.bmiHeader.biWidth = lngwidth
        s.bmiHeader.biPlanes = btMap.bmPlanes
        s.bmiHeader.biCompression = 0
        BytesPerScanLine = ((Abs(s.bmiHeader.biWidth) * 3) + 3) And &HFFFFFFFC
        s.bmiHeader.biSizeImage = BytesPerScanLine * lngheight
        Dim ImageData() As Byte
        ReDim ImageData(3, s.bmiHeader.biWidth, lngheight)
        GetDIBits ImageHDC, ImageBitmap, 0, lngheight, ImageData(0, 0, 0), s, 0
        If (ImageData(0, 0, 0) = 255) Then
            AO.AlphaFlags = 0
            AO.AlphaFormat = AC_SRC_ALPHA
            AO.AlphaOption = AC_SRC_OVER
            AO.SourceConstantAlpha = Transparency
            RtlMoveMemory PointerAlpha, AO, 4
            AlphaBlend DestinationHDC, 0, 0, lngwidth, lngheight, ImageHDC, 0, 0, lngwidth, lngheight, PointerAlpha
        Else
            AO.AlphaFlags = 0
            AO.AlphaFormat = AC_SRC_ALPHA
            AO.AlphaOption = AC_SRC_OVER
            AO.SourceConstantAlpha = 255 And GetPixel(ImageHDC, 1, 1)
            RtlMoveMemory PointerAlpha, AO, 4
            AlphaBlend DestinationHDC, 0, 0, lngwidth, lngheight, ImageHDC, 0, 0, lngwidth, lngheight, PointerAlpha
            TransparentBlt DestinationHDC, 0, 0, lngwidth, lngheight, ImageHDC, 0, 0, lngwidth, lngheight, ImageBackColor
        End If
    Else
        
        AO.AlphaFlags = 0
        AO.AlphaFormat = 0 'AC_SRC_ALPHA
        AO.AlphaOption = AC_SRC_OVER
        AO.SourceConstantAlpha = Transparency
        RtlMoveMemory PointerAlpha, AO, 4
        AlphaBlend DestinationHDC, 0, 0, lngwidth, lngheight, ImageHDC, 0, 0, lngwidth, lngheight, PointerAlpha
    End If
End Sub
these code draw's an image from ImageHDC.
but i see 2 things on image file:
1 - if the image have the background color transparent, the AlphaBlend() do, too, the transparent(avoiding the TransparentBlt());
2 - if the image don't have the background color transparent, the AlphaBlend() don't do the transparent thing.
my problem is draw the image transparent when the background color isn't transparent(in these case i can't use the TransparentBlt()). can anyone advice me?
Reply With Quote
Reply

Tags
lngheight, lngwidth, pointeralpha, alphablend, imagehdc, dim, transparent, destinationhdc, image, ac_src_over, ac_src_alpha, bytesperscanline, ao.alphaflags, ao.alphaformat, ao.alphaoption, ao.sourceconstantalpha, transparency, rtlmovememory, s.bmiheader.biwidth, color, background, imagedata0, btmap, s.bmiheader.biplanes, blntransparent


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images? AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
 
AlphaBlend: how use on non transparent images?
AlphaBlend: how use on non transparent images?
 
-->