Страница: 1 |
|
Вопрос: .png и Visual Basic 6
|
Добавлено: 28.06.11 14:06
|
|
Автор вопроса: FedX | ICQ: 578776900
|
Можно ли сделать так, чтобы VB6 читал png форматы?
Ответить
|
Номер ответа: 4 Автор ответа: Ким Чен Ир
Вопросов: 0 Ответов: 140
|
Профиль | | #4
|
Добавлено: 28.06.11 15:12
|
Я когда-то делал полупрозрачную сплэш-форму открывая через GDI+ GdipLoadImageFromFile.
Поискать?
Ответить
|
Номер ответа: 6 Автор ответа: Ким Чен Ир
Вопросов: 0 Ответов: 140
|
Профиль | | #6
|
Добавлено: 28.06.11 16:14
|
Дело было давно, но почему-то работает
- Option Explicit
-
- Private Const ULW_ALPHA = &H2
- Private Const AC_SRC_ALPHA As Long = &H1
- Private Const WS_EX_LAYERED = &H80000
- Private Const GWL_EXSTYLE As Long = -20
-
- Private Type Size
- cx As Long
- cy As Long
- End Type
-
- Private Type BITMAPINFOHEADER
- 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 BITMAPINFO
- bmiHeader As BITMAPINFOHEADER
- bmiColors As Long
- End Type
-
- Private Type BLENDFUNCTION
- BlendOp As Byte
- BlendFlags As Byte
- SourceConstantAlpha As Byte
- AlphaFormat As Byte
- End Type
-
- Private Type GdiplusStartupInput
- GdiplusVersion As Long
- DebugEventCallback As Long
- SuppressBackgroundThread As Long
- SuppressExternalCodecs As Long
- End Type
-
- Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Declare Function UpdateLayeredWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal hdcDst As Long, ByVal pptDst As Long, psize As Any, ByVal hdcSrc As Long, pptSrc As Long, ByVal crKey As Long, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Long) As Long
- Private Declare Function CreateDIBSection Lib "gdi32.dll" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByRef lplpVoid As Any, ByVal handle As Long, ByVal dw As Long) As Long
- Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
- Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
- Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
- Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, graphics As Long) As Long
- Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
- Private Declare Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal image As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
- Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, image As Long) As Long
- Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal image As Long, Width As Long) As Long
- Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal image As Long, Height As Long) As Long
- Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As Long
- Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal filename As Long, bitmap As Long) As Long
- Private Declare Function GdiplusStartup Lib "gdiplus" (Token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
- Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal Token As Long)
-
-
-
- Private Sub Form_Load()
- Dim memDC As Long
- Dim newBmp As Long
- Dim prvBmp As Long
- Dim BI As BITMAPINFO
- Dim Blend As BLENDFUNCTION
- Dim H As Long, W As Long
- Dim img As Long
- Dim graphics As Long
- Dim wz As Size
- Dim GpInput As GdiplusStartupInput
- Dim imgpath As String
-
- imgpath = "D:\splash.png"
-
- GpInput.GdiplusVersion = 1
- GdiplusStartup 0, GpInput
-
- With BI.bmiHeader
- .biSize = Len(BI.bmiHeader)
- .biBitCount = 32
- .biHeight = ScaleHeight
- .biWidth = ScaleWidth
- .biPlanes = 1
- .biSizeImage = .biWidth * .biHeight * (.biBitCount / 8)
- End With
-
- memDC = CreateCompatibleDC(hdc)
- newBmp = CreateDIBSection(memDC, BI, 0, 0, 0, 0)
- prvBmp = SelectObject(memDC, newBmp)
-
- GdipCreateFromHDC memDC, graphics
- GdipLoadImageFromFile StrConv(imgpath, vbUnicode), img
- GdipGetImageHeight img, H
- GdipGetImageWidth img, W
-
- GdipDrawImageRect graphics, img, 0, 0, W, H
-
- SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
-
- wz.cx = ScaleWidth
- wz.cy = ScaleHeight
-
- With Blend
- .AlphaFormat = AC_SRC_ALPHA
- .SourceConstantAlpha = 255
- End With
-
- GdipDisposeImage img
- GdipDeleteGraphics graphics
- UpdateLayeredWindow hwnd, hdc, 0, wz, memDC, 0, 0, Blend, ULW_ALPHA
- SelectObject memDC, prvBmp
- DeleteObject newBmp
- DeleteDC memDC
- End Sub
Ответить
|
Страница: 1 |
Поиск по форуму