Results 1 to 7 of 7

Thread: gdi question

  1. #1
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    gdi question

    hi all.

    does anybody knows more about UI / "GDIp" properties, commands and syntax ? manual help doesn't show any help.

    for example: "Gdip_GetImagePixelFormat" ?

    "Gdip_LoadImageFromFile(a(b) )" does probably exists

    [code=thinbasic]hGpBitmap = Gdip_GetImagePixelFormat(JPGFileName, nFormat)

    ...
    Case %PixelFormat1bppIndexed : strFormat = "1 bpp indexed"
    Case %PixelFormat4bppIndexed : strFormat = "4 bpp indexed"
    Case %PixelFormat8bppIndexed : strFormat = "8 bpp indexed"
    Case %PixelFormat16bppGrayScale : strFormat = "16 bpp gray scale"
    Case %PixelFormat16bppRGB555 : strFormat = "16 bpp RGB 555"
    Case %PixelFormat16bppRGB565 : strFormat = "16 bpp RGB 565"
    Case %PixelFormat16bppARGB1555 : strFormat = "16 bpp ARGB 1555"
    Case %PixelFormat24bppRGB : strFormat = "24 bpp RGB"
    Case %PixelFormat32bppRGB : strFormat = "32 bpp RGB"
    Case %PixelFormat32bppARGB : strFormat = "32 bpp ARGB"
    Case %PixelFormat32bppPARGB : strFormat = "32 bpp PARGB"
    Case %PixelFormat48bppRGB : strFormat = "48 bpp RGB"
    Case %PixelFormat64bppARGB : strFormat = "64 bpp ARGB"
    Case %PixelFormat64bppPARGB : strFormat = "64 bpp PARGB"

    End Select
    [/code]

    try to build a new GDIp example for thinbasic.

    any help about GDIp features would be nice. best regards, frank
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #2
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159
    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

  3. #3
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: gdi question

    yes, that's ok with link and I know such stuff, but I would like to know what's already possible with current thinbasic beta issue and existing GDIp examples ?

    "Gdip_GetImagePixelFormat" is still missing so far as I can check it.
    also: "%PixelFormat1bppIndexed".

    perhaps it's possible to realize this feature for next thinbasic release ? would be very nice to see that!

    many thanks, good night, frank
    you can't always get what you want, but if you try sometimes you might find, you get what you need

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

    Re: gdi question

    Frank if the information isn't included already then why not add it?

    [code=thinbasic]DECLARE FUNCTION GdipGetImagePixelFormat LIB "GDIPLUS.DLL" ALIAS "GdipGetImagePixelFormat" ( _
    BYVAL pimage AS DWORD _ ' GpImage *image
    , BYREF format AS LONG _ ' PixelFormat *format
    ) AS LONG ' GpStatus


    %PixelFormat1bppIndexed = 196865
    %PixelFormat4bppIndexed = 197634
    %PixelFormat8bppIndexed = 198659
    %PixelFormat16bppGrayScale = 1052676
    %PixelFormat16bppRGB555 = 135173
    %PixelFormat16bppRGB565 = 135174
    %PixelFormat16bppARGB1555 = 397319
    %PixelFormat24bppRGB = 137224
    %PixelFormat32bppRGB = 139273
    %PixelFormat32bppARGB = 2498570
    %PixelFormat32bppPARGB = 925707
    %PixelFormat48bppRGB = 1060876
    %PixelFormat64bppARGB = 3424269
    %PixelFormat64bppPARGB = 1851406
    %PixelFormat32bppCMYK = 8207
    %PixelFormatMax = 16
    [/code]
    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

  5. #5
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: gdi question

    thanks michael!

    ok, here my first attempt! but something important is still missing in code. to be truly, I am not very familiar with including freeImage.dll or gdiplus.dll for thinbasic. Need help, but it's exiting to see when script will work and run

    a) gdiplus.dll I have included
    b) example script for "Gdiplus Get_Export_list" properties is running fine ! (included in zip too)
    c) the example works with:
    "hStatus = GdipGetImagePixelFormat(JPGFileName, Counter)" so example counts Images and I noticed thinbasic knows "GdipGetImagePixelFormat" after including

    perhaps you or anybody else can check what's missing ? thanks in advance.

    my gdiplus test code example
    [code=thinbasic]
    '----------------------------------------------------------------------
    '------- testscript for GDIplus.dll from frank brübach (aka Lionheart)
    '----------------------------------------------------------------------

    uses "UI", "File"

    %PixelFormat1bppIndexed = 196865
    %PixelFormat4bppIndexed = 197634
    %PixelFormat8bppIndexed = 198659
    %PixelFormat16bppGrayScale = 1052676
    %PixelFormat16bppRGB555 = 135173
    %PixelFormat16bppRGB565 = 135174
    %PixelFormat16bppARGB1555 = 397319
    %PixelFormat24bppRGB = 137224
    %PixelFormat32bppRGB = 139273
    %PixelFormat32bppARGB = 2498570
    %PixelFormat32bppPARGB = 925707
    %PixelFormat48bppRGB = 1060876
    %PixelFormat64bppARGB = 3424269
    %PixelFormat64bppPARGB = 1851406
    %PixelFormat32bppCMYK = 8207
    %PixelFormatMax = 16


    Declare Function GdipGetImagePixelFormat Lib "GDIPLUS.DLL" Alias "GdipGetImagePixelFormat" ( _
    ByVal pimage As DWord _ ' GpImage *image
    , ByRef format As Long _ ' PixelFormat *format
    ) As Long ' GpStatus


    If Uses("GDIP") < 0 Then
    msgbox 0, "GDI+ lib not found"
    stop
    end if

    dim wWidth as long value 425
    dim wHeight as long value 425

    function TBMain()

    '------------------------------------------------------------------------------
    ' Create dialog
    '------------------------------------------------------------------------------
    dim hDlg as dword
    Dialog NEW PIXELS, 0, "thinBasic using GDI+ Test", -1, -1, wWidth, wHeight, _
    %WS_DLGFRAME OR _
    %DS_CENTER OR _
    %WS_CAPTION OR _
    %WS_SYSMENU OR _
    0 TO hDlg

    '------------------------------------------------------------------------------
    ' Show dialog
    '------------------------------------------------------------------------------
    DIALOG SHOW modal hDlg, call dlgCallback

    end function

    callback function dlgCallback() as long
    Dim ImagesDir As String = APP_SourcePath + "Images\"
    Dim JPGFileName As String = APP_SourcePath + "Images\incredibles.jpg"
    dim lWidth as long
    dim lHeight as long
    dim nFiles as long
    dim sFiles() as string
    dim Counter as long
    dim x as long
    dim y as long
    dim cWidth as long
    dim cHeight as long
    Dim cForLine As Long
    Local hStatus As Long
    Local pImage As DWord
    Local strFileName As String '= APP_SourcePath + "Images\incredibles.jpg"
    Local nFormat As Long
    Local strFormat As String '= APP_SourcePath + "Images\incredibles.jpg"

    Dim hBitmap, hGpBitmap, pThumbnail As Long

    select case cbMsg

    case %WM_INITDIALOG
    '------------------------------------------------------------------------------
    ' Create controls and Load images
    '------------------------------------------------------------------------------
    nFiles = DIR_ListArray(sFiles, ImagesDir, "*.*", %FILE_NORMAL Or %FILE_ADDPATH)

    x = 5
    y = 5
    cForLine = 4
    cWidth = (wWidth - (x * (cForLine + 2)) ) / cForLine
    cHeight = cWidth

    for Counter = 1 to nFiles

    CONTROL ADD LABEL, cbHndl, 1000 + Counter, "", x, y, cWidth, cHeight, %SS_SUNKEN or %SS_BITMAP

    '---Create an image handle
    hGpBitmap = GDIP_CreateBitMapFromFile(sFiles(Counter))
    '---Get image W and H
    lWidth = GDIP_GetImageWidth(hGpBitmap)
    lHeight = GDIP_GetImageHeight(hGpBitmap)
    '---Alternative way to get width and height directly from file:
    GDIp_GetImageSizeFromFile(JPGFileName, lWidth, lHeight)

    pThumbnail = GDIp_GetImageThumbnail(hGpBitmap, cWidth, cHeight)

    '---Convert to a hBitbam handle
    hBitmap = GDIp_HBitMapFromBitmap(pThumbnail)
    '---Release GDI image
    GDIP_DisposeImage(hGpBitmap)
    GDIP_DisposeImage(pThumbnail)

    'hStatus = Gdip_LoadImageFromFile(sFiles(Counter))
    'hGpBitmap = Gdip_LoadImageFromFile(sFiles(Counter))

    hStatus = GdipGetImagePixelFormat(JPGFileName, Counter)
    hGpBitmap = GdipGetImagePixelFormat(JPGFileName, nFormat)
    hGpBitmap = GdipGetImagePixelFormat(JPGFileName, pThumbnail)

    Select Case pThumbnail '-Counter
    Case %PixelFormat1bppIndexed : strFormat = "1 bpp indexed"
    Case %PixelFormat4bppIndexed : strFormat = "4 bpp indexed"
    Case %PixelFormat8bppIndexed : strFormat = "8 bpp indexed"
    Case %PixelFormat16bppGrayScale : strFormat = "16 bpp gray scale"
    Case %PixelFormat16bppRGB555 : strFormat = "16 bpp RGB 555"
    Case %PixelFormat16bppRGB565 : strFormat = "16 bpp RGB 565"
    Case %PixelFormat16bppARGB1555 : strFormat = "16 bpp ARGB 1555"
    Case %PixelFormat24bppRGB : strFormat = "24 bpp RGB"
    Case %PixelFormat32bppRGB : strFormat = "32 bpp RGB"
    Case %PixelFormat32bppARGB : strFormat = "32 bpp ARGB"
    Case %PixelFormat32bppPARGB : strFormat = "32 bpp PARGB"
    Case %PixelFormat48bppRGB : strFormat = "48 bpp RGB"
    Case %PixelFormat64bppARGB : strFormat = "64 bpp ARGB"
    Case %PixelFormat64bppPARGB : strFormat = "64 bpp PARGB"
    Case Else : strFormat = Format$(pThumbnail)'(nFormat) '(Counter)
    End Select

    MsgBox 0, "The pixel format of the image is " & strFormat, %MB_ICONINFORMATION, "gdiplus_pixel test"

    CONTROL SEND cbHndl, 1000 + Counter, %STM_SETIMAGE, %IMAGE_BITMAP, hBitmap

    '---Release temp hBitmap
    object_delete(hBitmap)
    'control set resize hDlg, 1000 + Counter, 0, 1, 0, 0

    x += 5 + cWidth
    if mod(Counter, cForLine) = 0 then
    x = 5
    y += 5 + cHeight
    end if

    next

    end select

    end function

    [/code]

    last edit: update the code example with little success this version seems to run and show results with

    [code=thinbasic]"hGpBitmap = GdipGetImagePixelFormat(JPGFileName, pThumbnail)"[/code]

    seven messages will appear for testing: for example

    the pixelformat of the image is: 24552584 (24525184)
    perhaps anybody can check this code too if it's running on his machine.

    best regards, frank
    Attached Images Attached Images
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  6. #6

    Re: gdi question

    Quote Originally Posted by Lionheart008
    yes, that's ok with link and I know such stuff, but I would like to know what's already possible with current thinbasic beta issue and existing GDIp examples ?

    "Gdip_GetImagePixelFormat" is still missing so far as I can check it.
    also: "%PixelFormat1bppIndexed".

    perhaps it's possible to realize this feature for next thinbasic release ? would be very nice to see that!

    many thanks, good night, frank
    Franck, open up a request topic so your wish doesn't get burried inside the topic.

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

    Re: gdi question

    Thanks Michale for the suggestion.
    Forum is becoming quite big so a little of "methodology" is necessary.

    Eros
    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

Similar Threads

  1. C to TB question
    By Michael Clease in forum Other languages
    Replies: 2
    Last Post: 03-06-2010, 12:11
  2. m15 question
    By kryton9 in forum M15 file format
    Replies: 4
    Last Post: 20-06-2007, 20:18

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
  •