Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: tb_graphx

  1. #21

    Re: tb_graphx

    Most likely any windows api needs a pointer to a null terminated string. So if you want to parse a string,

    1) define strFileName as an ASCII string withz maybe 256 characters of length
    2) Your StrPtr approach should work then.

    Look into the source of my TBDI module. Look where I load the effect files. Should work similar.

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

    Re: tb_graphx

    Also do not forget the string has to be unicode, so UCODE$ should serve well.


    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

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

    Re: tb_graphx

    thanks michael, petr

    do for me a little favour? somebody can test this tb example ? would be nice to hear what kind of results you're getting.

    I am thinking it's just missing one special line or command at powerbasic side, so this part is ready and I can load images (png, jpg, bmp).

    simple test example only for feedback:
    [code=thinbasic] '------------------------------------------------------------------------------
    ' Load needed modules
    '------------------------------------------------------------------------------
    Uses "UI", "console"
    Module "graphx_1xy"

    '------------------------------------------------------------------------------
    ' Equates
    '------------------------------------------------------------------------------
    Begin Const
    %lImage = 1000
    %lImage2
    %lText
    End Const

    Function TBMain()
    '---Test if module was loaded. If not, abort!
    If Uses("GDIP") < 0 Then
    MsgBox 0, "GDI+ lib not found"
    Stop
    End If

    '------------------------------------------------------------------------------
    ' Create dialog
    '------------------------------------------------------------------------------
    Dim hDlg As DWord

    Dialog New Pixels, 0, "frankos thinBasic using tb_graphx/GDI+", -1, -1, 400, 326, _
    %WS_DLGFRAME Or _
    %DS_CENTER Or _
    %WS_CAPTION Or _
    %WS_SYSMENU Or _
    %WS_CLIPCHILDREN Or _
    %WS_OVERLAPPEDWINDOW, _
    0 To hDlg

    '------------------------------------------------------------------------------
    ' Show dialog
    '------------------------------------------------------------------------------
    Dialog SHOW MODAL hDlg, Call dlgCallback

    End Function
    '------------------------------------------------------------------------------
    ' Main loop
    '------------------------------------------------------------------------------
    CallBack Function dlgCallback() As Long
    Dim JPGFileName As Asciiz*256 = APP_SourcePath + "Images\ferrari-enzo.png"
    Dim JPGFileName2 As Asciiz*256 = APP_SourcePath + "Images\leoparden1.png"
    Dim strFileName As Asciiz*256 = APP_SourcePath + "Images\leoparden1.png"
    Dim strUFileName As Asciiz*256 = APP_SourcePath + "Images\leoparden1.png" 'String
    Dim lWidth As Long
    Dim lWidth1 As Long
    Dim lHeight As Long
    Dim lHeight1 As Long
    Dim hBitmap,hBitmap1, hGpBitmap,hGpBitmap1, pImage, pGraphics,pThumbnail As Long
    Dim x,y,z,v,v1 As Long
    Dim nThumbnailWidth, nThumbnailHeight As Long

    Select Case CBMSG

    Case %WM_INITDIALOG
    '------------------------------------------------------------------------------
    ' Create constrols and Load images
    '------------------------------------------------------------------------------
    Control Add Label, CBHNDL, %lImage,"", 40, 40, 420, 310, %SS_BITMAP

    v = DrawImageRect(hGpBitmap1, hBitmap, 10, 10, 400, 400)

    MsgBox 0, "getImageThumbnail feedback: " + GetImageThumbnail(hGpBitmap,40,40,10,10,10)
    MsgBox 0, "yes DrawImageRect!: " + DrawImageRect(hGpBitmap,hBitmap, 10,10,200,200)

    lWidth = ImageWidth(hGpBitmap,10)
    MsgBox 0, "width ok? " + lWidth
    lHeight = ImageHeight(hGpBitmap,20)
    MsgBox 0, "height ok? " + lHeight

    MsgBox 0, "load image ok: " + LoadImageFromFile(JPGFileName2, hBitmap)

    MsgBox 0, "pic: " + StrPtr(jpgfilename2) '--> only for test purpose


    Control Send CBHNDL, %lImage, %STM_SETIMAGE, %IMAGE_BITMAP, hBitmap
    Control Redraw CBHNDL, %lImage

    Control Add Label, CBHNDL, %lText, "thinBasic tb_graphx/GDI+ module wrapper example (" & lWidth & " x " & lHeight & ")", 0, 311, 400, 15, %SS_CENTER
    Control SET COLOR CBHNDL, %lText, RGB(0,0,0), RGB(255,128,0)
    Control REDRAW CBHNDL, %lText

    Control Set Resize CBHNDL, %lImage, 1, 1, 1, 1
    Control SET RESIZE CBHNDL, %lText , 1, 1, 0, 1

    DoEvents

    Case %WM_SIZE
    Control Redraw CBHNDL, %lImage

    Case %WM_CLOSE
    ' -- Erase resources
    '---Release temp hBitmap
    Object_Delete(hBitmap)
    '---Release GDI image
    'GDIP_DisposeImage(hGpBitmap)

    End Select
    'PrintL GetImageThumbnail(hGpBitmap,40,40,10,10,10)
    End Function[/code]

    all you need I send as zip file. / I will break through this wall and understand gdiplus

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

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

    Re: tb_graphx

    hello all.

    sorry, no new success but ten per cent smarter, some explanations and notices:

    Load image can handle bitmaps, cursors and icons, not .jpg, .gif or .png files.
    That's the main reason why I don't get any picture to show at my display. I will find a new way. I have done everything right with parsing and compiling. It's just the cored disadvantage why gdiplus don't load straight the way png, jpgs or gifs. Now I know why you can only use BMP Files for loading and then converting in jpgs, png's and much more. my idea was to load png, jpgs via directly input.

    ...Before discussing the code itself, there is a caveat with GDI+ that must be addressed. With JPG, some TIFF and other formats, the original image information must be available at all times. In other words, if you open a bitmap using Bitmap::FromFile, you cannot delete or otherwise change that file while the image is open. This same restriction applies to CGdiPlusBitmapResource. (My testing found that PNG and BMP files don't seem to follow this generalization, though I don't know if this is standard behavior or just a fluke with my file set.)...
    It takes only three days to find this error behaviour. Good to know and learn much more about gdiplus. If there is any new success in this direction I will show my results.

    At the moment I have few time because there are some professional things I am involved, but I will have a closer look at this "tb_graphx" chapter, because I will get the gold medaille to win this little eager cup to calm my own curiosity

    After a bit of testing and several errors, due mostly to the horrible GDI+ documentation, I came up with working code. After a night of rest, I decided to encapsulate the code in a simple class to ensure memory got freed. The result were two classes: "CGdiPlusBitmap" and "CGdiPlusBitmapResource".
    If I load one of my first example with steer powerbasic created dialog (included gdiplus feature) I can load this PNG, JPG, GIF image I wished to have but not for thinbasic side. This lacked hole I will find to solve.

    thanks for taking attention. best regards, frank lionhead
    you can't always get what you want, but if you try sometimes you might find, you get what you need

Page 3 of 3 FirstFirst 123

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
  •