Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-ide
Commits
37ebeee6
Commit
37ebeee6
authored
Dec 19, 2001
by
Diederik van Arkel
Browse files
Add patched osbitmap
parent
f2e87cae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Win/PatchConsoleEvents/osbitmap.dcl
0 → 100644
View file @
37ebeee6
definition
module
osbitmap
// Clean object I/O library, version 1.2
import
ospicture
::
Bitmap
::
OSBitmap
=
{
originalSize
::
!(!
Int
,!
Int
)
// The size of the bitmap
,
reSize
::
!(!
Int
,!
Int
)
// to store values passed to resizeBitmap
,
bitmapContents
::
!{#
Char
}
// The (device independent) bitmap information (for printing)
,
bitmapHandle
::
!
Int
// The handle to the screen bitmap (for screen)
}
toBitmap
::
!
OSBitmap
->
Bitmap
fromBitmap
::
!
Bitmap
->
OSBitmap
// osReadBitmap reads a bitmap from a file.
osReadBitmap
::
!*
File
->
(!
Bool
,!
OSBitmap
,!*
File
)
// osGetBitmapSize returns the size of the bitmap
osGetBitmapSize
::
!
OSBitmap
->
(!
Int
,!
Int
)
// osGetBitmapContent returns the content string of the bitmap
osGetBitmapContent
::
!
OSBitmap
->
{#
Char
}
// osGetBitmapHandle returns the handle of the bitmap
osGetBitmapHandle
::
!
OSBitmap
->
Int
/* osResizeBitmap (w,h) bitmap
resizes the argument bitmap to the given size.
It is assumed that w and h are not negative.
*/
osResizeBitmap
::
!(!
Int
,!
Int
)
!
OSBitmap
->
OSBitmap
/* osDrawBitmap bitmap pos origin isScreenOutput pictContext
draws the argument bitmap with the left top corner at pos, given the current origin and drawing context.
The isScreenOutput MUST be False when producing printer output. For screen output this is not the case,
but setting it to True is much more efficient.
*/
osDrawBitmap
::
!
OSBitmap
!(!
Int
,!
Int
)
!(!
Int
,!
Int
)
!
Bool
!
OSPictContext
!*
OSToolbox
->
(!
OSPictContext
,!*
OSToolbox
)
Win/PatchConsoleEvents/osbitmap.icl
0 → 100644
View file @
37ebeee6
implementation
module
osbitmap
// PA: other version of bitmaps: create a bitmap handle instead of continuesly copying String to OS
import
StdArray
,
StdBool
,
StdChar
,
StdClass
,
StdInt
,
StdFile
,
StdTuple
import
ospicture
,
ostoolbox
,
pictCCall_12
::
Bitmap
=
OSBitmap
!
OSBitmap
::
OSBitmap
=
{
originalSize
::
!(!
Int
,!
Int
)
// The size of the bitmap
,
reSize
::
!(!
Int
,!
Int
)
// to store values passed to resizeBitmap
,
bitmapContents
::
!{#
Char
}
// The (device independent) bitmap information (for printing)
,
bitmapHandle
::
!
Int
// The handle to the screen bitmap (for screen)
}
toBitmap
::
!
OSBitmap
->
Bitmap
toBitmap
osBitmap
=
OSBitmap
osBitmap
fromBitmap
::
!
Bitmap
->
OSBitmap
fromBitmap
(
OSBitmap
osBitmap
)
=
osBitmap
// osReadBitmap reads a bitmap from a file. See page 176 of Programming Windows 95 (Charles Petzold)
osReadBitmap
::
!*
File
->
(!
Bool
,!
OSBitmap
,!*
File
)
osReadBitmap
file
#
(_,
c1
,
file
)
=
freadc
file
#
(
ok
,
c2
,
file
)
=
freadc
file
// read first two bytes
|
not
ok
||
c1
<>
'B'
||
c2
<>
'M'
// are they "BM"?
=
(
False
,
noBitmap
,
file
)
#
(_,
fileSize
,
file
)
=
freadi
file
// read file size
#
(_,
_,
file
)
=
freadi
file
// skip bfReserved1 & 2
#
(_,
_,
file
)
=
freadi
file
// skip bfOffBits
#
(_,
_,
file
)
=
freadi
file
// skip biSize
#
(_,
w
,
file
)
=
freadi
file
// read width
#
(
ok1
,
h
,
file
)
=
freadi
file
// read height
#
(
ok2
,
file
)
=
fseek
file
0
FSeekSet
|
not
ok1
||
not
ok2
=
(
False
,
noBitmap
,
file
)
#
(
data
,
file
)
=
freads
file
fileSize
|
size
data
<>
fileSize
=
(
False
,
noBitmap
,
file
)
|
otherwise
#
(
hdc
,
tb
)
=
winCreateScreenHDC
OSNewToolbox
#
(
hbmp
,
tb
)
=
winCreateBitmap
w
data
hdc
tb
#
tb
=
winDestroyScreenHDC
(
hdc
,
tb
)
=
(
if
(
tb
==
OSDummyToolbox
)
True
True
,{
originalSize
=(
w
,
h
),
reSize
=(
w
,
h
),
bitmapContents
=
data
,
bitmapHandle
=
hbmp
},
file
)
where
noBitmap
=
{
originalSize
=(
0
,
0
),
reSize
=(
0
,
0
),
bitmapContents
={},
bitmapHandle
=
0
}
// osGetBitmapSize returns the size of the bitmap.
osGetBitmapSize
::
!
OSBitmap
->
(!
Int
,!
Int
)
osGetBitmapSize
{
reSize
}
=
reSize
// osGetBitmapContent returns the content string of the bitmap
osGetBitmapContent
::
!
OSBitmap
->
{#
Char
}
osGetBitmapContent
{
bitmapContents
}
=
bitmapContents
// osGetBitmapHandle returns the handle of the bitmap
osGetBitmapHandle
::
!
OSBitmap
->
Int
osGetBitmapHandle
{
bitmapHandle
}
=
bitmapHandle
/* osResizeBitmap (w,h) bitmap
resizes the argument bitmap to the given size.
It is assumed that w and h are not negative.
*/
osResizeBitmap
::
!(!
Int
,!
Int
)
!
OSBitmap
->
OSBitmap
osResizeBitmap
size
bitmap
=
{
bitmap
&
reSize
=
size
}
/* osDrawBitmap bitmap pos origin pictContext
draws the argument bitmap with the left top corner at pos, given the current origin and drawing context.
*/
osDrawBitmap
::
!
OSBitmap
!(!
Int
,!
Int
)
!(!
Int
,!
Int
)
!
Bool
!
OSPictContext
!*
OSToolbox
->
(!
OSPictContext
,!*
OSToolbox
)
osDrawBitmap
{
originalSize
,
reSize
,
bitmapContents
,
bitmapHandle
}
pos
=:(
px
,
py
)
origin
=:(
ox
,
oy
)
isScreenOutput
pictContext
tb
|
isScreenOutput
|
originalSize
==
reSize
=
winDrawBitmap
originalSize
destination
bitmapHandle
(
pictContext
,
tb
)
// otherwise
=
winDrawResizedBitmap
originalSize
destination
reSize
bitmapHandle
(
pictContext
,
tb
)
|
otherwise
=
winPrintResizedBitmap
originalSize
destination
reSize
bitmapContents
(
pictContext
,
tb
)
where
destination
=
(
px
-
ox
,
py
-
oy
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment