Created
May 23, 2014 03:55
-
-
Save fowlmouth/950c998b7de5f9663af5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| Bitmap = ref PBitmap | |
| PBitmap = ptr object | |
| w,h: int | |
| proc load_bitmap_pvt (file:cstring): PBitmap {.importc:"bitmap_load".} | |
| proc destroy (bmp:PBitmap) {.importc:"bitmap_destroy".} | |
| proc free (B:Bitmap) = | |
| destroy B.bmp | |
| proc load_bitmap (file:string): Bitmap = | |
| var b = load_bitmap_pvt(file) | |
| if not b.isNil: | |
| new(result, free) | |
| result[] = b | |
| let b = load_bitmap("ello.bmp") | |
| echo b.w,"x",b.h | |
| # we can define this so Bitmap converts automatically to PBitmap | |
| converter tobmp (b:Bitmap):PBitmap = b[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment