Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

FabPaintLib and bBrowser 03 Sep 2022 12:25 #23613

  • alex_schmitt
  • alex_schmitt's Avatar
  • Topic Author


  • Posts: 44
  • Dear all,

    I have a bBrowser with a Data Column that displays pictures. In X# the behavior is different than in VO and the picure is not drawn correctly, i.e. partially cut off or scaled weirdly.
    To boil down the problem I have adapted Joachim's original example from the bBrowser samples and changed the
    bimgCreateBitmapFromDibString() to use FabPaintLib.
    Result is, that no image is drawn at all but if I debug the GetImage Function, the object FabImage object seems to be valid.
    PARTIAL CLASS dtwBitmaps INHERIT _dtwBitmaps
    
    
    CONSTRUCTOR(oWindow,iCtlID,oServer,uExtra)  
       SUPER(oWindow,iCtlID,oServer,uExtra)
       RETURN
    
    METHOD GetImage_Original(oServer)  // original method from Joachim. Works fine.
    	// Bild aus dem Server ermitteln
    	LOCAL oImage		AS bBitmap
    	LOCAL cDibData		AS STRING
    
    	// Bild als String aus dem Server ermitteln
    	cDibData := oServer:FieldGet(#IMAGE)	// stattdessen FieldGet() verwendet, bis der Fehler behoben ist.
    	IF !Empty(cDibData)
    		// Bild in ein Bitmap-Objekt konvertieren
    		oImage := bBitmap{bimgCreateBitmapFromDibString(, cDibData)}
    	ENDIF
    	RETURN oImage
    	
    	
    	
    METHOD GetImage(oServer) // adapted method, does not yield any picture in the colum. File exists.
    	LOCAL oFabImage AS FabPaintLib.FabPaintLib
    	LOCAL cThumbnailName AS STRING
    
    	cThumbnailName := "C:\temp\test.jpg"
    	
    	IF File(cThumbnailName) //if thumbnail is already there; just take this one
    		oFabImage := FabPaintLib.FabPaintLib{cThumbnailName, SELF}
    	ELSE 
    		QOut("Error")
    	ENDIF
    	
    RETURN oFabImage
    
    METHOD PostInit() 
    	// Fenster und Browser initialisieren
    	LOCAL odbsServer		AS OBJECT
    	LOCAL oColumn			AS bDataColumn
    	LOCAL oFabImage AS FabPaintLib.FabPaintLib
    
    	// Fenster initialisieren
    	SUPER:PostInit()
    	SetDeleted(TRUE)
    
    	// Server IMAGE öffnen
    	odbsServer := bDBServer{"..\..\Data\Image", TRUE, FALSE, "DBFCDX"}
    
    	IF odbsServer:Used
    		// Browser initialisieren
    		SELF:oDCBrowser:EnableRowHeightVariable(TRUE)
    		SELF:oDCBrowser:Use(odbsServer,, {#IMAGE_NAME})
    
    		// Spalte IMAGE_NAME initialisieren
    		oColumn := SELF:oDCBrowser:GetColumn(#IMAGE_NAME)
    		IF oColumn<>NULL_OBJECT
    			oColumn:Caption := "Name"
    		ENDIF
            
    		// Spalte IMAGE initialisieren
    		oColumn := bDataColumn{SELF:oDCBrowser, odbsServer, {|Server, Owner| Owner:GetImage(Server)}, #Expression, SELF}
    		
    		oColumn:Caption := "Image"
    		oColumn:ValType := "O"
    		oColumn:Alignment := BALIGN_CENTER
    		oColumn:Width := 299
    		SELF:oDCBrowser:AddColumn(oColumn)
    		SELF:oDCBrowser:OpenColumn(oColumn)
    
    		// Browser aktualisieren
    		SELF:oDCBrowser:Recalculate()
    	ENDIF
    
    	RETURN SELF
    
    END CLASS

    Does anybody have a similar issue and could resolve it?

    An old thread indicated similar problems and that it could be related to bBrowser drawing rather than FabPaintLib:

    groups.google.com/g/comp.lang.clipper.vi...bjects/c/QFn-AI1N950



    Best,
    Alex
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by alex_schmitt.

    FabPaintLib and bBrowser 13 Sep 2022 22:04 #23800

    • alex_schmitt
    • alex_schmitt's Avatar
    • Topic Author


  • Posts: 44
  • Hey all,

    or to put it the other way round:

    Is anybody in this group using pictures in a bBrowser - not necessarily FabPaintLib-based, and is successfull in doing so?
    Any hint would be super cool.
    I am still stuck without major progress.

    Best,
    Alex

    Please Log in or Create an account to join the conversation.

    FabPaintLib and bBrowser 13 Sep 2022 22:28 #23801

    • ic2
    • ic2's Avatar


  • Posts: 1553
  • Hello Alex,

    A few remarks:

    1 What is bBitmap, used in the original code?

    2 What happens if you create the image object using the general .Net Bitmap class? You can then assign the width & height, so if it displays something but still with the wrong scale, you could check if changing width/height fixes it.

    The general (C#) code for that would be:
    Bitmap bmp = new Bitmap('some.bmp');
    Bitmap bmp2 = new Bitmap(bmp, bmp.Width*0.5, bmp.Height*0.5); // 50%

    3 Is there a difference when you show it on a monitor with a different resolution/DPI? See

    stackoverflow.com/questions/60247409/ima...he-secondary-monitor

    Dick

    Please Log in or Create an account to join the conversation.

    FabPaintLib and bBrowser 13 Sep 2022 22:33 #23802

    • ic2
    • ic2's Avatar


  • Posts: 1553
  • One more thing:

    I have not used images in bBrowser except icons, but what if bBrowser requires a BLOB? The help isn't specific about this.

    Then you may need to convert your bitmap and it would explain why a FabPaint object doesn't show. Here's again some C# code which is doing that:

    stackoverflow.com/questions/11340854/convert-bitmap-to-byte

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    FabPaintLib and bBrowser 13 Sep 2022 23:30 #23804

    • alex_schmitt
    • alex_schmitt's Avatar
    • Topic Author


  • Posts: 44
  • Thanks for getting back, Dick.

    bBitmap is just an extended VO.Bitmap:
    CLASS bBitmap INHERIT Bitmap
    
    CONSTRUCTOR(uPara1, uPara2) 
    	IF PCount()=0
    		// mache nichts
    	ELSEIF IsPtr(uPara1)
    		SELF:hBitmap := uPara1
    	ELSE
    		SUPER(uPara1, uPara2)
    	ENDIF
    	RETURN 
    
    METHOD SetHandle(hBitmap) 
    	// Bitmap-Handle setzen
    	IF SELF:hBitmap<>NULL_PTR
    		DeleteObject(SELF:hBitmap)
    	ENDIF
    	SELF:hBitmap := hBitmap
    	RETURN TRUE
    
    END CLASS

    I tried to use C# already before, but my reading is that
    Bitmap bmp = new Bitmap('some.bmp');

    is System.Drawing.Bitmap whereas bBrowser would expect a VO.Bitmap.

    Not sure how to make them compatible.

    Haven't tried with different monitors yet and also not the BLOB idea. Will check it out, too.

    Best,
    Alex

    Please Log in or Create an account to join the conversation.

    FabPaintLib and bBrowser 14 Sep 2022 13:21 #23811

    • Fabrice
    • Fabrice's Avatar


  • Posts: 299
  • Hi Alex,
    sorry if I didn't jump in before...As I don't use, and don't have bBrowser.

    Just to test/check, is it possible to have a FabPaintCtrl on the Window that you refresh every times you select another line, and draw the image there ? ... Just to be sure that FabPaint is able to draw a correct image.

    Fab

    Please Log in or Create an account to join the conversation.

    Last edit: by Fabrice.

    FabPaintLib and bBrowser 15 Sep 2022 23:03 #23868

    • alex_schmitt
    • alex_schmitt's Avatar
    • Topic Author


  • Posts: 44
  • Dear Fabrice, Dick,

    Thanks for your further hints.

    I could finally manage to successfully draw the picture by converting a System.Drawing.Bitmap into a VO.Bitmap.
    INTERNAL FUNCTION getVOBitmap(cFilename as STRING) AS VO.Bitmap PASCAL
    
    	LOCAL oStream AS System.IO.MemoryStream
    	LOCAL oNetBitmap AS System.Drawing.Bitmap
        
        LOCAL aImageData AS BYTE[]
    	LOCAL hBitmap AS PTR    
        
        TRY
    		aImageData := System.IO.File.ReadAllBytes(cFilename)
    	CATCH e AS Exception
    		THROW InvalidOperationException{ "Image data not readable.", e }
    	END TRY
    	    
    	IF ( aImageData?:Length ?? 0 ) == 0
    		THROW ArgumentException{ "Image data is empty." }
    	ENDIF
    		
    	TRY
    		oStream := System.IO.MemoryStream{ aImageData }
    		oNetBitmap := System.Drawing.Bitmap{ oStream }
    	CATCH e AS Exception
    		THROW InvalidOperationException{ "Image data is broken.", e }
    	END TRY
    	
    	hBitmap := CopyImage(oNetBitmap:GetHbitmap(), IMAGE_BITMAP, oNetBitmap:Width, oNetBitmap:Height, LR_COPYDELETEORG)
    
    	RETURN VO.Bitmap{ hBitmap }
    

    This solution goes without FabPaint but as long as it works I am fine :)

    Best,
    Alex

    Please Log in or Create an account to join the conversation.

    FabPaintLib and bBrowser 16 Sep 2022 13:40 #23886

    • Joachim Bieler
    • Joachim Bieler's Avatar


  • Posts: 36
  • Hi Alex,
    please excuse me for getting involved so late.
    Can you send me an example application with which I can reproduce the problem. Maybe I can extend the bBrowser for X# so that this problem no longer occurs.
    Regards
    Joachim Bieler

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1