Results 1 to 14 of 14

Thread: Getting a black (transparent) image instead of white

Threaded View

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Getting a black (transparent) image instead of white

    Hi (will post the image)
    I have a white png transpaent Image that I try to resize and make transparent.
    the problem is that I get returned with a black non transparent Image.
    Any ideas?
    Haven't tried without the encoder yet.
    It may make a difference
    Code:
     Using dbmp = New Bitmap(dWidth, dHeight)
                        Using sbmp As New Bitmap(strImageSource)
    
    
                                dbmp.MakeTransparent(System.Drawing.Color.White)
                                sbmp.MakeTransparent(System.Drawing.Color.White)
    
                       
    
                            sbmp.SetResolution(DPI, DPI)               
                            gr = Graphics.FromImage(dbmp)                    
                            gr.DrawImage(sbmp, 0, 0, dWidth, dHeight) 
    
                          
    
                      
                            Dim jpgEncoder As ImageCodecInfo
                         
                                jpgEncoder = clsgen.GetEncoder(ImageFormat.Png)
                         
    
    
                            ' Create an Encoder object based on the GUID
                            ' for the Quality parameter category.
                            ''''This may or may not make a difference on the black transparent image, M trying as I post it....''''
    
                            Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
                          
                            Dim myEncoderParameters As New EncoderParameters(1)
    
                            Dim myEncoderParameter As New EncoderParameter(myEncoder, 100L)  
                            myEncoderParameters.Param(0) = myEncoderParameter
    
                            Try
                                dbmp.Save(strImageDestination, jpgEncoder, myEncoderParameters)
    
    
    ''''''encoder function
     Protected Friend Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo
    
            Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()
            Dim codec As ImageCodecInfo
            For Each codec In codecs
                If codec.FormatID = format.Guid Then
                    Return codec
                End If
            Next codec
            Return Nothing
    
        End Function
    Attached Images Attached Images  
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width