Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

.Png in Game


thales12
 Share

Recommended Posts

First Download this dll: [http://www.4shared.com/rar/QKyPrUVyba/PaintX.html](http://www.4shared.com/rar/QKyPrUVyba/PaintX.html)

Put it in your game folder.

Open **Client~Side**:

then go to > Project > References > Browse > Paintx.dll select the dll and click Ok.

at the end of the mod add DirectDraw7:

```

Public Function LoadPNG(fileName As String, Optional Errore As Boolean) As StdPicture
On Error GoTo er:
Dim PictureDecoder As New PAINTXLib.PictureDecoder
Set LoadPNG = PictureDecoder.LoadPicture(fileName)
Exit Function
er:
If Errore Then MsgBox "Erreur de chargement de " & fileName & vbCrLf & "Verifiez qu'il soit présent."
End Function

Public Function LoadImage(fileName As String, DDraw As DirectDraw7, SDesc As DDSURFACEDESC2) As DirectDrawSurface7
Dim TPict As StdPicture
Set TPict = LoadPNG(fileName, True)

SDesc.lHeight = CLng((TPict.Height * 0.001) * 567 / Screen.TwipsPerPixelY)
SDesc.lWidth = CLng((TPict.Width * 0.001) * 567 / Screen.TwipsPerPixelX)

Set LoadImage = DDraw.CreateSurface(SDesc)

Dim SDC As Long, TDC As Long
SDC = LoadImage.GetDC
TDC = CreateCompatibleDC(0)
SelectObject TDC, TPict.Handle

BitBlt SDC, 0, 0, SDesc.lWidth, SDesc.lHeight, TDC, 0, 0, vbSrcCopy

LoadImage.ReleaseDC SDC
DeleteDC TDC

Set TPict = Nothing
End Function

Public Function LoadImageStretch(fileName As String, Height As Long, Width As Long, DDraw As DirectDraw7, SDesc As DDSURFACEDESC2) As DirectDrawSurface7
Dim TPict As New StdPicture
Set TPict = LoadPNG(fileName, True)

SDesc.lHeight = Height
SDesc.lWidth = Width

Set LoadImageStretch = DDraw.CreateSurface(SDesc)

Dim SDC As Long, TDC As Long
SDC = LoadImageStretch.GetDC
TDC = CreateCompatibleDC(0)
SelectObject TDC, TPict.Handle

StretchBlt SDC, 0, 0, Width, Height, TDC, 0, 0, CLng((TPict.Width * 0.001) * 567 / Screen.TwipsPerPixelX), CLng((TPict.Height * 0.001) * 567 / Screen.TwipsPerPixelY), vbSrcCopy

LoadImageStretch.ReleaseDC SDC
DeleteDC TDC

Set TPict = Nothing
End Function

```

On top fashion directdraw7 add:

```

Public 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
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal HDC As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal HDC As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal HDC As Long, ByVal hObject As Long) As Long
Public Declare Function StretchBlt Lib "gdi32" (ByVal HDC 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Sub outportb Lib "PaintX.dll" (ByVal PortAddress As Integer, ByVal PortData As Byte)
Private Declare Function inportb Lib "PaintX.dll" (ByVal PortAddress As Integer) As Byte

```
search for:

```

Public Const GFX_EXT As String = ".bmp"

```
Chage by:

```

Public Const GFX_EXT As String = ".png"

```
Search for:

```

Set Surf = DD.CreateSurfaceFromFile(fileName, SurfDesc)

```

change by:

```

Set Surf = LoadImage(fileName, DD, SurfDesc)

```

Ready now you can use images .png.

Credits: Thales at the dll and declare tutorial
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...