"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.08.1-source/examples/manual/gfx/imageinfo.bas" (6 Jul 2021, 921 Bytes) of package /linux/privat/FreeBASIC-1.08.1-source.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "imageinfo.bas": 1.08.0_vs_1.08.1.

    1 '' examples/manual/gfx/imageinfo.bas
    2 ''
    3 '' NOTICE: This file is part of the FreeBASIC Compiler package and can't
    4 ''         be included in other distributions without authorization.
    5 ''
    6 '' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgImageInfo
    7 '' --------
    8 
    9 '' Create 32-bit graphics screen and image.
   10 ScreenRes 320, 200, 32
   11 Dim image As Any Ptr = ImageCreate( 64, 64 )
   12 
   13 Dim pitch As Long
   14 Dim pixels As Any Ptr
   15 
   16 '' Get enough information to iterate through the pixel data.
   17 If 0 <> ImageInfo( image, ,,, pitch, pixels ) Then
   18     Print "unable to retrieve image information."
   19     Sleep
   20     End
   21 End If
   22 
   23 '' Draw a pattern on the image by directly manipulating pixel memory.
   24 For y As Integer = 0 To 63
   25     Dim row As ULong Ptr = pixels + y * pitch
   26     
   27     For x As Integer = 0 To 63
   28         row[x] = RGB(x * 4, y * 4, (x Xor y) * 4)
   29     Next x
   30 Next y
   31 
   32 '' Draw the image onto the screen.
   33 Put (10, 10), image
   34 
   35 ImageDestroy( image )
   36 
   37 Sleep