Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: string to bitmap module

  1. #1
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    string to bitmap module

    Here is a module for converting 256 colour bitmaps to 24 bit bitmaps, its still very primitive at the moment so be gentle with it.

    [code=thinbasic]
    '----------------------------------------------------------------------------------------------------
    ' Usage: ReturnString = TBGF_String2Bitmap (stringbuffer, RGBformat)
    ' Stringbuffer is a string - which contains a valid bitmap file loaded into memory.
    ' RGBformat is
    ' %TBGF_BGRformat = &H00000001 which returns image data as B G R (valid bitmap file)
    ' %TBGF_RGBformat = &H00000002 which returns image data as R G B
    ' %TBGF_RGBAformat = &H00000004 which returns image data as R G B A
    ' %TBGF_File = &H00000008 Filebuffer is a filename to load.
    ' %TBGF_Buffer = &H00000010 FileBuffer is a bitmap file in a STRING
    '
    ' ReturnString is a string - which contains a valid 24 bit bitmap file
    ' this is only for development when TBGL string is supported only the bitmap data will be returned.
    '
    ' if stringbuffer does not contain a valid bitmap structure ReturnString = ""
    '---------------------------------------------------------------------------------------------------
    [/code]

    if you load a 24 bit bitmap it only returns the bitmap data (ie. not a valid file, headers stripped)

    have fun.
    Attached Files Attached Files
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: string to bitmap module

    Thanks Abraxas for the new module, but I am getting this error, forgive me if I am doing something stupid in getting this error.
    It might be that the dll is not named thinBasic_name of dll, but not sure.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: string to bitmap module

    Ok, it was the naming... I changed the name of the dll to: thinBasic_TBGF.dll

    in the script I changed the line: MODULE "TBGF_MODULEV0.1.0"
    to: USES "TBGF"

    It then works fine.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  4. #4

    Re: string to bitmap module

    Thanks for the module!

    Kent, the error has to do with a bug that Eros just recently fixed and released a new Core.


  5. #5
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: string to bitmap module

    also didnt help I changed the module version numbering at the last minute and didnt post that version.

    fixed now renamed module to thinBasic_TBGF.dll, you now need to copy to the mod directory inside thinbasic directory.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: string to bitmap module

    Hi Abraxas,

    thanks a lot. On my PC it works ok, I just added to script "USES "TBGF"" as I am more used to it.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: string to bitmap module

    Thanks a lot Abraxas.

    Nice and useful module. If you want, I can create a dedicated forum for this module. I have the impression some other functionalities can be added to it
    Also, when you think will be the right time, I can include in standard thinBasic release adding help info too.
    Just let me know.

    Possible implementations:
    • load and save of the BMP files can be native TBGF module functions.
      This will avoid the necessity to have FILE module loaded (I can show you FILE_LOAD/FILE_SAVE source code)
    • Change RGBFormat into more general options paremeter using HEX values. In this case more options acan be passed. Example:
      TBGF_BGRformat = &H00000001
      %TBGF_RGBformat = &H00000002
      %TBGF_RGBAformat = &H00000004
      %TBGF_File = &H00000008
      %TBGF_Buffer = &H00000010
      In this way, testing it, buffer can be either the name of a bitmap file or a real memory buffer and it can be used like:
      TBGF_String2Bitmap (stringbuffer, %TBGF_File OR %TBGF_RGBformat)
      or
      TBGF_String2Bitmap (stringbuffer, %TBGF_Buffer OR %TBGF_RGBformat)


    Just mad ideas, you know how we are ;D

    In any case, thanks a lot for this idea.
    Eros

    @Ken,
    here the bug Abraxas reported: http://community.thinbasic.com/index...sg8502#msg8502
    It will be fixed in next release.
    In any case just use USES "TBGF" and all should be ok.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: string to bitmap module

    ok. look up ;D
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  9. #9
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: string to bitmap module

    Eros i would be interested in seeing the File_load and save routines,as I know this will improve my simple routines that are in place now.

    if you dont mind please email to my account address.

    is my current version working OK.

    thanks your help is as always much appreciated

    Mike
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: string to bitmap module

    Here they are PB source.
    They can be improved maybe wrapping arounf TRY/CATCH/END TRY

    [code=vb]
    FUNCTION File_Exists(BYVAL FullFileName AS STRING) AS LONG
    FUNCTION = %FALSE
    IF DIR$(FullFileName, %NORMAL OR %READONLY OR %HIDDEN OR %SYSTEM) = "" THEN EXIT FUNCTION
    FUNCTION = %TRUE
    END FUNCTION

    FUNCTION FILE_Load(BYVAL lFileName AS STRING) AS STRING
    LOCAL hFile AS LONG
    LOCAL lBuffer AS STRING

    ON ERROR RESUME NEXT
    IF FILE_EXISTS(lFileName) THEN
    hFile = FREEFILE
    OPEN lFileName FOR BINARY ACCESS READ AS hFile
    GET$ hFile, LOF(hFile), lBuffer
    CLOSE hFile
    FUNCTION = lBuffer
    END IF

    END FUNCTION

    FUNCTION FILE_Save(BYVAL lFileName AS STRING, BYVAL sBuffer AS STRING) AS LONG
    LOCAL hFile AS LONG

    ON ERROR RESUME NEXT
    IF FILE_EXISTS(lFileName) THEN
    KILL lFileName
    END IF
    hFile = FREEFILE
    OPEN lFileName FOR BINARY ACCESS READ WRITE AS hFile
    PUT$ hFile, sBuffer
    CLOSE hFile
    FUNCTION = ERRCLEAR

    END FUNCTION
    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 1 of 2 12 LastLast

Similar Threads

  1. bitmap font
    By kryton9 in forum TBGL General
    Replies: 6
    Last Post: 26-04-2007, 20:53

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •