Ergebnis 1 bis 4 von 4
-
Bin neu hier
- 27.08.2008, 13:44
- #1
hallo zusammen
weiss jemand ob es möglich ist ein bild in einer picturebox durchscheinend zu machen? Ich will den Hintergrund durchscheinen lassen. Ich verwende visual studio 2008.
Danke
-
- 27.08.2008, 15:14
- #2
also, du kannst entweder ein ELEMENT.BackColor = transparent versuchen.
andernfalls kannst du auch ein bitmap laden, welches einen transparenten hintergrund enthält (die palette muss entsprechend sein, gibt es ein extra menü dafür).
oder aber diese Funktion (frei nach CodeGuru (Englisch)) verwenden:
Code:Sub TransparentBlt(dsthDC As Long, srchDC As Long, X As Integer, _ Y As Integer, Width As Integer, _ Height As Integer, TransColor As Long) Dim maskDC As Long 'DC for the mask Dim tempDC As Long 'DC for temporary data Dim hMaskBmp As Long 'Bitmap for mask Dim hTempBmp As Long 'Bitmap for temporary data 'First, create some DC's. These are our gateways to associated 'bitmaps in RAM maskDC = CreateCompatibleDC(dsthDC) tempDC = CreateCompatibleDC(dsthDC) 'Then, we need the bitmaps. Note that we create a monochrome 'bitmap here! 'This is a trick we use for creating a mask fast enough. hMaskBmp = CreateBitmap(Width, Height, 1, 1, ByVal 0&) hTempBmp = CreateCompatibleBitmap(dsthDC, Width, Height) 'Then we can assign the bitmaps to the DCs hMaskBmp = SelectObject(maskDC, hMaskBmp) hTempBmp = SelectObject(tempDC, hTempBmp) 'Now we can create a mask. First, we set the background color 'to the transparent color; then we copy the image into the 'monochrome bitmap. 'When we are done, we reset the background color of the 'original source. TransColor = SetBkColor(srchDC, TransColor) BitBlt maskDC, 0, 0, Width, Height, srchDC, 0, 0, vbSrcCopy TransColor = SetBkColor(srchDC, TransColor) 'The first we do with the mask is to MergePaint it into the 'destination. 'This will punch a WHITE hole in the background exactly were 'we want the graphics to be painted in. BitBlt tempDC, 0, 0, Width, Height, maskDC, 0, 0, vbSrcCopy BitBlt dsthDC, X, Y, Width, Height, tempDC, 0, 0, vbMergePaint 'Now we delete the transparent part of our source image. To do 'this, we must invert the mask and MergePaint it into the 'source image. The transparent area will now appear as WHITE. BitBlt maskDC, 0, 0, Width, Height, maskDC, 0, 0, vbNotSrcCopy BitBlt tempDC, 0, 0, Width, Height, srchDC, 0, 0, vbSrcCopy BitBlt tempDC, 0, 0, Width, Height, maskDC, 0, 0, vbMergePaint 'Both target and source are clean. All we have to do is to AND 'them together! BitBlt dsthDC, X, Y, Width, Height, tempDC, 0, 0, vbSrcAnd 'Now all we have to do is to clean up after us and free system 'resources.. DeleteObject (hMaskBmp) DeleteObject (hTempBmp) DeleteDC (maskDC) DeleteDC (tempDC) End Sub
-
entwickelt Apps
- 27.08.2008, 17:30
- #3
Link zu einem Beispiel mit dem AlphaBlend API im zweiten Posting und eine einfache Art im dritten Posting.
http://forums.microsoft.com/MSDN/Sho...76600&SiteID=1
-
Bin neu hier
- 28.08.2008, 14:05
- #4
Danke euch für die Antworten. Werde demnächst versuchen die Sache zu Ende zu bringen und den hoffentlichen Erfolg posten
Ähnliche Themen
-
Das wichtigste zum Yakumo alpha & delta - Bitte zuerst lesen
Von juelu im Forum Forum andere Hersteller (PPC)Antworten: 1Letzter Beitrag: 14.06.2010, 17:39 -
Beta(alpha?)-Tester für mein Spiel gesucht!
Von KoMaXX im Forum ProgrammierenAntworten: 20Letzter Beitrag: 22.06.2008, 11:36 -
Lingvosoft 2008
Von M0rph im Forum ÜbersetzungssoftwareAntworten: 1Letzter Beitrag: 21.11.2007, 19:24
Pixel 10 Serie mit Problemen:...