Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: .png и Visual Basic 6 Добавлено: 28.06.11 14:06  

Автор вопроса:  FedX | ICQ: 578776900 
Можно ли сделать так, чтобы VB6 читал png форматы?

Ответить

  Ответы Всего ответов: 7  

Номер ответа: 1
Автор ответа:
 FedX



ICQ: 578776900 

Вопросов: 4
Ответов: 10
 Профиль | | #1 Добавлено: 28.06.11 14:08
Простите, не png форматы, а png файлы.

Ответить

Номер ответа: 2
Автор ответа:
 AgentFire



ICQ: 192496851 

Вопросов: 75
Ответов: 3178
 Профиль | | #2 Добавлено: 28.06.11 14:30
Можно.

Ответить

Номер ответа: 3
Автор ответа:
 FedX



ICQ: 578776900 

Вопросов: 4
Ответов: 10
 Профиль | | #3 Добавлено: 28.06.11 14:34
как?

Ответить

Номер ответа: 4
Автор ответа:
 Ким Чен Ир



Вопросов: 0
Ответов: 140
 Профиль | | #4 Добавлено: 28.06.11 15:12
Я когда-то делал полупрозрачную сплэш-форму открывая через GDI+ GdipLoadImageFromFile.
Поискать?

Ответить

Номер ответа: 5
Автор ответа:
 FedX



ICQ: 578776900 

Вопросов: 4
Ответов: 10
 Профиль | | #5 Добавлено: 28.06.11 15:40
Если не трудно, поищите, пожалуйста.

Ответить

Номер ответа: 6
Автор ответа:
 Ким Чен Ир



Вопросов: 0
Ответов: 140
 Профиль | | #6 Добавлено: 28.06.11 16:14
Дело было давно, но почему-то работает:)
  1. Option Explicit
  2.  
  3. Private Const ULW_ALPHA = &H2
  4. Private Const AC_SRC_ALPHA As Long = &H1
  5. Private Const WS_EX_LAYERED = &H80000
  6. Private Const GWL_EXSTYLE As Long = -20
  7.  
  8. Private Type Size
  9.     cx As Long
  10.     cy As Long
  11. End Type
  12.  
  13. Private Type BITMAPINFOHEADER
  14.     biSize As Long
  15.     biWidth As Long
  16.     biHeight As Long
  17.     biPlanes As Integer
  18.     biBitCount As Integer
  19.     biCompression As Long
  20.     biSizeImage As Long
  21.     biXPelsPerMeter As Long
  22.     biYPelsPerMeter As Long
  23.     biClrUsed As Long
  24.     biClrImportant As Long
  25. End Type
  26.  
  27. Private Type BITMAPINFO
  28.     bmiHeader As BITMAPINFOHEADER
  29.     bmiColors As Long
  30. End Type
  31.  
  32. Private Type BLENDFUNCTION
  33.     BlendOp As Byte
  34.     BlendFlags As Byte
  35.     SourceConstantAlpha As Byte
  36.     AlphaFormat As Byte
  37. End Type
  38.  
  39. Private Type GdiplusStartupInput
  40.     GdiplusVersion As Long
  41.     DebugEventCallback As Long
  42.     SuppressBackgroundThread As Long
  43.     SuppressExternalCodecs As Long
  44. End Type
  45.  
  46. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  47. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  48. 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
  49. 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
  50. Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
  51. Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
  52. Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
  53. Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, graphics As Long) As Long
  54. Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
  55. 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
  56. Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, image As Long) As Long
  57. Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal image As Long, Width As Long) As Long
  58. Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal image As Long, Height As Long) As Long
  59. Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As Long
  60. Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal filename As Long, bitmap As Long) As Long
  61. Private Declare Function GdiplusStartup Lib "gdiplus" (Token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
  62. Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal Token As Long)
  63.  
  64.  
  65.  
  66. Private Sub Form_Load()
  67.     Dim memDC As Long
  68.     Dim newBmp As Long
  69.     Dim prvBmp As Long
  70.     Dim BI As BITMAPINFO
  71.     Dim Blend As BLENDFUNCTION
  72.     Dim H As Long, W As Long
  73.     Dim img As Long
  74.     Dim graphics As Long
  75.     Dim wz As Size
  76.     Dim GpInput As GdiplusStartupInput
  77.     Dim imgpath As String
  78.     '
  79.     imgpath = "D:\splash.png"
  80.     
  81.     GpInput.GdiplusVersion = 1
  82.     GdiplusStartup 0, GpInput
  83.  
  84.     With BI.bmiHeader
  85.         .biSize = Len(BI.bmiHeader)
  86.         .biBitCount = 32
  87.         .biHeight = ScaleHeight
  88.         .biWidth = ScaleWidth
  89.         .biPlanes = 1
  90.         .biSizeImage = .biWidth * .biHeight * (.biBitCount / 8)
  91.     End With
  92.  
  93.     memDC = CreateCompatibleDC(hdc)
  94.     newBmp = CreateDIBSection(memDC, BI, 0, 0, 0, 0)
  95.     prvBmp = SelectObject(memDC, newBmp)
  96.         
  97.     GdipCreateFromHDC memDC, graphics
  98.     GdipLoadImageFromFile StrConv(imgpath, vbUnicode), img
  99.     GdipGetImageHeight img, H
  100.     GdipGetImageWidth img, W
  101.     
  102.     GdipDrawImageRect graphics, img, 0, 0, W, H
  103.     
  104.     SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
  105.    
  106.     wz.cx = ScaleWidth
  107.     wz.cy = ScaleHeight
  108.         
  109.     With Blend
  110.         .AlphaFormat = AC_SRC_ALPHA
  111.         .SourceConstantAlpha = 255
  112.     End With
  113.     
  114.     GdipDisposeImage img
  115.     GdipDeleteGraphics graphics
  116.     UpdateLayeredWindow hwnd, hdc, 0, wz, memDC, 0, 0, Blend, ULW_ALPHA
  117.     SelectObject memDC, prvBmp
  118.     DeleteObject newBmp
  119.     DeleteDC memDC
  120. End Sub

Ответить

Номер ответа: 7
Автор ответа:
 FedX



ICQ: 578776900 

Вопросов: 4
Ответов: 10
 Профиль | | #7 Добавлено: 28.06.11 22:05
Спасибо большое!

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам