Accueil > > > UNE GRANDE DÉCOUVERTE GRAPHIQUE
UNE GRANDE DÉCOUVERTE GRAPHIQUE
Information sur la source
Description
Plusieurs programmeurs sur visual basic cherche a crée des effets graphique. Mes le problème et le temps de la réalisation. J'ai retrouve la solution pour faire des effets plus vite..
Source
- Private Const BI_RGB = 0&
- Private Const DIB_RGB_COLORS = 0 ' color table in RGBs
- Private Type BITMAPINFOHEADER '40 bytes
- biSize As Long
- biWidth As Long
- biHeight As Long
- biPlanes As Integer
- biBitCount As Integer
- biCompression As Long
- biSizeImage As Long
- biXPelsPerMeter As Long
- biYPelsPerMeter As Long
- biClrUsed As Long
- biClrImportant As Long
- End Type
- Private Type RGBQUAD
- rgbBlue As Byte
- rgbGreen As Byte
- rgbRed As Byte
- rgbReserved As Byte
- End Type
- Private Type BITMAPINFO
- bmiHeader As BITMAPINFOHEADER
- bmiColors As RGBQUAD
- End Type
- Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
- Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
- Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
- Private Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
- Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
- Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
- Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
- Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
- Dim iBitmap As Long, iDC As Long
-
-
-
- Public Sub CreateEff(Eff As String, OrgHdc As Long, vW As Single, vH As Single, Newhdc As Long)
- On Error Resume Next
- Dim bi24BitInfo As BITMAPINFO, bBytes() As Byte, Cnt As Long
-
-
- With bi24BitInfo.bmiHeader
- .biBitCount = 24
- .biCompression = BI_RGB
- .biPlanes = 1
- .biSize = Len(bi24BitInfo.bmiHeader)
- .biWidth = vW
- .biHeight = vH
- End With
-
- ReDim bBytes(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 4) As Byte
- iDC = CreateCompatibleDC(OrgHdc)
- iBitmap = CreateDIBSection(iDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
- SelectObject iDC, iBitmap
- BitBlt iDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, OrgHdc, 0, 0, vbSrcCopy
- GetDIBits iDC, iBitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
-
- Select Case Eff
- Case "Inverse"
- For Cnt = LBound(bBytes) To UBound(bBytes)
- bBytes(Cnt) = 255 - bBytes(Cnt)
- Next Cnt
- Case "Ombre"
- For Cnt = LBound(bBytes) To UBound(bBytes)
- bBytes(Cnt) = bBytes(Cnt) * 0.5
- Next Cnt
- Case "Cellule"
- For Cnt = LBound(bBytes) To UBound(bBytes)
- mutip = Tan(Abs(Cos(Abs(((Cnt * 50) / (15)))))) / 1.5
- If Int(bBytes(Cnt) * mutip) > 255 Then
- bBytes(Cnt) = (bBytes(Cnt))
- Else
- bBytes(Cnt) = Int(bBytes(Cnt) * mutip)
- End If
- Next Cnt
- Case "Confus"
- For Cnt = LBound(bBytes) To UBound(bBytes)
- mutip = (bBytes(Cnt)) Xor 25
- bBytes(Cnt) = mutip
- Next Cnt
- Case "Clear"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- mutip = bBytes(Cnt) * 0.9
- bBytes(Cnt) = (mutip)
- Next Cnt
- Case "Blue"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- bBytes(Cnt + 1) = 0
- bBytes(Cnt + 2) = 0
- Next Cnt
- Case "Green"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- bBytes(Cnt) = 0
- bBytes(Cnt + 2) = 0
- Next Cnt
- Case "Red"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- bBytes(Cnt) = 0
- bBytes(Cnt + 1) = 0
- Next Cnt
- Case "Soft"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- bBytes(Cnt) = GetMin(bBytes(Cnt) * Tan(Abs(Cos(Cnt * 2))))
- bBytes(Cnt + 1) = GetMin(bBytes(Cnt + 1) * Tan(Abs(Cos(Cnt * 2))))
- bBytes(Cnt + 2) = GetMin(bBytes(Cnt + 2) * Tan(Abs(Cos(Cnt * 2))))
- Next Cnt
- Case "Change"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- mbd = bBytes(Cnt)
- mvd = bBytes(Cnt + 1)
- mrd = bBytes(Cnt + 2)
- bBytes(Cnt) = mvd
- bBytes(Cnt + 1) = mrd
- bBytes(Cnt + 2) = mbd
- Next Cnt
- Case "Noir et Blanc"
- For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
- mbd = bBytes(Cnt)
- mvd = bBytes(Cnt + 1)
- mrd = bBytes(Cnt + 2)
- bBytes(Cnt) = mvd
- bBytes(Cnt + 1) = mvd
- bBytes(Cnt + 2) = mvd
- Next Cnt
- Case "Dark"
- For Cnt = LBound(bBytes) To UBound(bBytes) - 3 Step 3
- bBytes(Cnt) = bBytes(Cnt) * Cnt / UBound(bBytes)
- bBytes(Cnt + 1) = bBytes(Cnt + 1) * Cnt / UBound(bBytes)
- bBytes(Cnt + 2) = bBytes(Cnt + 2) * Cnt / UBound(bBytes)
- Next Cnt
- End Select
- SetDIBitsToDevice Newhdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
- DeleteDC iDC
- DeleteObject iBitmap
- End Sub
-
-
-
-
- Public Function GetMin(v1)
- GetMin = v1
- If v1 > 255 Then
- GetMin = 255
- End If
- If v1 < 0 Then
- GetMin = 0
- End If
- End Function
Private Const BI_RGB = 0&
Private Const DIB_RGB_COLORS = 0 ' color table in RGBs
Private Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Dim iBitmap As Long, iDC As Long
Public Sub CreateEff(Eff As String, OrgHdc As Long, vW As Single, vH As Single, Newhdc As Long)
On Error Resume Next
Dim bi24BitInfo As BITMAPINFO, bBytes() As Byte, Cnt As Long
With bi24BitInfo.bmiHeader
.biBitCount = 24
.biCompression = BI_RGB
.biPlanes = 1
.biSize = Len(bi24BitInfo.bmiHeader)
.biWidth = vW
.biHeight = vH
End With
ReDim bBytes(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 4) As Byte
iDC = CreateCompatibleDC(OrgHdc)
iBitmap = CreateDIBSection(iDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
SelectObject iDC, iBitmap
BitBlt iDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, OrgHdc, 0, 0, vbSrcCopy
GetDIBits iDC, iBitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
Select Case Eff
Case "Inverse"
For Cnt = LBound(bBytes) To UBound(bBytes)
bBytes(Cnt) = 255 - bBytes(Cnt)
Next Cnt
Case "Ombre"
For Cnt = LBound(bBytes) To UBound(bBytes)
bBytes(Cnt) = bBytes(Cnt) * 0.5
Next Cnt
Case "Cellule"
For Cnt = LBound(bBytes) To UBound(bBytes)
mutip = Tan(Abs(Cos(Abs(((Cnt * 50) / (15)))))) / 1.5
If Int(bBytes(Cnt) * mutip) > 255 Then
bBytes(Cnt) = (bBytes(Cnt))
Else
bBytes(Cnt) = Int(bBytes(Cnt) * mutip)
End If
Next Cnt
Case "Confus"
For Cnt = LBound(bBytes) To UBound(bBytes)
mutip = (bBytes(Cnt)) Xor 25
bBytes(Cnt) = mutip
Next Cnt
Case "Clear"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
mutip = bBytes(Cnt) * 0.9
bBytes(Cnt) = (mutip)
Next Cnt
Case "Blue"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
bBytes(Cnt + 1) = 0
bBytes(Cnt + 2) = 0
Next Cnt
Case "Green"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
bBytes(Cnt) = 0
bBytes(Cnt + 2) = 0
Next Cnt
Case "Red"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
bBytes(Cnt) = 0
bBytes(Cnt + 1) = 0
Next Cnt
Case "Soft"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
bBytes(Cnt) = GetMin(bBytes(Cnt) * Tan(Abs(Cos(Cnt * 2))))
bBytes(Cnt + 1) = GetMin(bBytes(Cnt + 1) * Tan(Abs(Cos(Cnt * 2))))
bBytes(Cnt + 2) = GetMin(bBytes(Cnt + 2) * Tan(Abs(Cos(Cnt * 2))))
Next Cnt
Case "Change"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
mbd = bBytes(Cnt)
mvd = bBytes(Cnt + 1)
mrd = bBytes(Cnt + 2)
bBytes(Cnt) = mvd
bBytes(Cnt + 1) = mrd
bBytes(Cnt + 2) = mbd
Next Cnt
Case "Noir et Blanc"
For Cnt = LBound(bBytes) To UBound(bBytes) Step 3
mbd = bBytes(Cnt)
mvd = bBytes(Cnt + 1)
mrd = bBytes(Cnt + 2)
bBytes(Cnt) = mvd
bBytes(Cnt + 1) = mvd
bBytes(Cnt + 2) = mvd
Next Cnt
Case "Dark"
For Cnt = LBound(bBytes) To UBound(bBytes) - 3 Step 3
bBytes(Cnt) = bBytes(Cnt) * Cnt / UBound(bBytes)
bBytes(Cnt + 1) = bBytes(Cnt + 1) * Cnt / UBound(bBytes)
bBytes(Cnt + 2) = bBytes(Cnt + 2) * Cnt / UBound(bBytes)
Next Cnt
End Select
SetDIBitsToDevice Newhdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
DeleteDC iDC
DeleteObject iBitmap
End Sub
Public Function GetMin(v1)
GetMin = v1
If v1 > 255 Then
GetMin = 255
End If
If v1 < 0 Then
GetMin = 0
End If
End Function
Conclusion
Exemple :
CreateEff "Inverse",Picture1.hdc, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc CreateEff "Clear",Picture1.hdc, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|