Update savebinarypbm.bm
This commit is contained in:
parent
ae9d84a33e
commit
32e3ed4cb6
1 changed files with 6 additions and 4 deletions
|
|
@ -6,31 +6,33 @@ Sub saveBinaryPBM (handle As Long, filename As String)
|
|||
Dim y As _Unsigned Long
|
||||
Dim x As _Unsigned Long
|
||||
Dim bytecount As _Unsigned Long
|
||||
Dim ff As Long
|
||||
Dim c As _Byte
|
||||
Dim outbyte As _Unsigned _Byte
|
||||
oldsource = _Source
|
||||
_Source handle
|
||||
imgwidth = _Width(handle)
|
||||
imgheight = _Height(handle)
|
||||
Open filename For Binary As #1
|
||||
ff = FreeFile
|
||||
Open filename For Binary As #ff
|
||||
header = "P4" + Chr$(10)
|
||||
header = header + "# Created with QB64" + Chr$(10)
|
||||
header = header + LTrim$(Str$(imgwidth) + Str$(imgheight)) + Chr$(10)
|
||||
Put #1, , header
|
||||
For y = 0 To imgheight - 1
|
||||
For x = 0 To imgwidth - 1
|
||||
c = (Point(x, y) = _RGB(0, 0, 0))
|
||||
c = (Point(x, y) = _RGB32(0, 0, 0))
|
||||
If c <> 0 Then
|
||||
outbyte = _SetBit(outbyte, 7 - (bytecount Mod 8))
|
||||
Else
|
||||
outbyte = _ResetBit(outbyte, 7 - (bytecount Mod 8))
|
||||
End If
|
||||
If bytecount Mod 8 = 7 Then
|
||||
Put #1, , outbyte
|
||||
Put #ff, , outbyte
|
||||
End If
|
||||
bytecount = bytecount + 1
|
||||
Next
|
||||
Next
|
||||
If (imgheight * imgwidth) Mod 8 <> 0 Then Put #1, , outbyte
|
||||
Close #1
|
||||
Close #ff
|
||||
End Sub
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue