Compile causes Memory accessviolation

Blitz3D Forums/Blitz3D Programming/Compile causes Memory accessviolation

WillKoh(Posted 2005) [#1]
Bellow is poor but working little utility for viewing a picture brighter than normal, but it causes memory access violation when used by a "view bright" option on an image file type (jpg). The command is just "bright.exe" "%1"


Graphics 1024, 768, 32, 1
i = LoadImage(CommandLine$())

SetFont LoadFont("ms sans serif",10)

Text 32, 0, "Viewing: " + CommandLine$()
Text 32, 15, "Working..."

iw = ImageWidth(i)
ih = ImageHeight(i)
SetBuffer ImageBuffer(i)
LockBuffer()
For x = 0 To iw - 1
For y = 0 To ih - 1
p = ReadPixelFast(x, y)
brpix = getrgb(Getr(p) * 1.25, Getg(p) * 1.25, Getb(p) * 1.25)
WritePixelFast x, y, brpix
Next
Next
UnlockBuffer()

SetBuffer FrontBuffer()
DrawBlock i, 32, 55
Text 32, 35, "Done"
While(1)
If MouseHit(1) Or MouseHit(2) Or MouseHit(3) Or KeyHit(1) Or KeyHit(57) Or KeyHit(28) Then
End
End If
Wend


Function GetRGB(r,g,b,a=255)
Return (a Shl 24) Or (r Shl 16) Or (g Shl 8) Or b
End Function

Function getr(rgb)
Return (rgb And $00FF0000) Shr 16
End Function

Function getg(rgb)
Return (rgb And $0000FF00) Shr 8
End Function

Function getb(rgb)
Return (rgb And $000000FF)
End Function


WillKoh(Posted 2005) [#2]
Sorry, now it works, it was the DDE message that was enabled