Hello Michael,
> Is someone willing to share how to load JPGs in a bBrowser?
Run the bSample - Images (import from you bBrowser\Samples directory)
- it's all there.
HTH,
Marcos Nogueira
S. Paulo - Brazil
This is a discussion on JPGs, etc in bBrowser - Clipper ; Hello All, Is someone willing to share how to load JPGs in a bBrowser? TIA, Michael...
Hello All,
Is someone willing to share how to load JPGs in a bBrowser?
TIA,
Michael
Hello Michael,
> Is someone willing to share how to load JPGs in a bBrowser?
Run the bSample - Images (import from you bBrowser\Samples directory)
- it's all there.
HTH,
Marcos Nogueira
S. Paulo - Brazil
Marcos, thanks for the reply. When I looked at that sample, it seemed
that it only worked for bitmaps. Am I missing something?
Michael
Marcos Nogueira wrote:
> Hello Michael,
> > Is someone willing to share how to load JPGs in a bBrowser?
> Run the bSample - Images (import from you bBrowser\Samples directory)
> - it's all there.
>
> HTH,
>
> Marcos Nogueira
> S. Paulo - Brazil
Michal,
Some code,
In some bbrowser i show or hide a column of thumbnails depending of
the user choice,
look the method ShowThumbnails().
I hope this help you.
Paulo Oliveira
METHOD GetImage(oServer) CLASS DWAmostras
// this method creates, for the current recno of the server, a
thumbnail image
// on disk and returns this to the bBrowser.
// once the thumbnail exists, it will next time be returned
instead of created;
// We save the thumbnails in a temp folder, and give them a
name whcih is the RECNO+".JPG"
// (the recno is unique for this DBF. This technique will not
work O.K if you want to
// display images in several browsers with diffrent DBF's
linked to them!
// IN that case you'll have to generate a more unique name!
LOCAL oReturnImage AS bBitmap
LOCAL oFabImage AS USUAL
LOCAL cFileName,cCaminho,cNome AS STRING
LOCAL nHeight,nWidth AS LONG
LOCAL nMaxDim,r8Scalefactor,nNewHeight, nNewWidth AS REAL8
cCaminho:=POGetAppObject():cImg_Path+"\AMOSTRAS"
IF File(AllTrim(cCaminho)+"\"+AllTrim(oServer:cImagem)) //if
thumbnail already there; just take this one
cFileName := AllTrim(AllTrim(cCaminho)
+"\"+AllTrim(oServer:cImagem))
oFabImage := FabPaintLib{cFileName, SELF}
nHeight := oFabImage:Height
nWidth := oFabImage:Width
nMaxDim := Max(nHeight, nWidth) // determine bigest
dimension
// determine scalefactor in relation to 100 pixels
(because we want to resize to 100 pixels)
r8Scalefactor := 50/nMaxDim
nNewHeight := nHeight*r8Scalefactor
nNewWidth := nWidth*r8Scalefactor
oFabImage:ResizeBilinear(nNewWidth, nNewHeight)//
transform to 32 bpp
oReturnImage := bBItmap{oFabImage:Handle(),} //
create Image object and pass handle
ELSE
oFabImage := FabPaintLib{}
oFabImage:CreateFromResourceName(_GetInst(),"SEM_IMAGEM")
nHeight := oFabImage:Height
nWidth := oFabImage:Width
nMaxDim := Max(nHeight, nWidth) // determine bigest
dimension
// determine scalefactor in relation to 100 pixels
(because we want to resize to 100 pixels)
r8Scalefactor := 50/nMaxDim
nNewHeight := nHeight*r8Scalefactor
nNewWidth := nWidth*r8Scalefactor
oFabImage:ResizeBilinear(nNewWidth, nNewHeight)//
transform to 32 bpp
oReturnImage := bBItmap{oFabImage:Handle(),} // create
Image object and pass handle
ENDIF
RETURN oReturnImage
METHOD ShowThumbnails() CLASS DWAmostras
LOCAL oColumn AS bDataColumn
// thumbnails on
IF SELF:lVeImagens
SELFDCbBDetalheBase:EnableRowHeightVariable(TRUE)
SELFDCbBDetalheBase:RowHeightMax := 50
SELFDCbBDetalheBase:RowHeight:=50
// initialize virtual column IMAGE
SELFointer := Pointer{POINTERHOURGLASS}
oColumn := bDataColumn{SELFDCbBDetalheBase,; // owner of the
column
SELFDCbBDetalheBase:Server,; // server where
to check expression
{|Server, arg| arg:GetImage(Server)},; //
uExpression
#Expression,; // symFieldmode
SELF} // argument --> SELF:GetImage()
oColumn:Caption := "FOTO"
oColumn:Hyperlabel := Hyperlabel{#FOTO}
oColumn:ValType := "O" // type is an Object! (image)
oColumn:Alignment := BALIGN_CENTER
oColumn:Width := 50 // make column 100 pixels wide
oColumn:Resizable := FALSE
SELFDCbBDetalheBase:SuspendNotification()
SELFDCbBDetalheBase:AddCOlumn(oColumn)
IF SELF:lMostraSel
SELFDCbBDetalheBase:OpenColumn(oColumn,2) //
Segunda coluna
ELSE
SELFDCbBDetalheBase:OpenColumn(oColumn,1) // Primeira coluna
ENDIF
SELFDCbBDetalheBase:Recalculate()
SELFDCbBDetalheBase:Refresh()
SELFointer := Pointer{POINTERARROW}
SELFDCbBDetalheBase:ResetNotification()
SELFDCbBDetalheBase:SetFocus()
ELSE
oColumn := SELFDCbBDetalheBase:GetColumn(#FOTO)
IF oColumn <> NULL_OBJECT
SELFDCbBDetalheBase:RemoveColumn(oColumn,FALSE)
SELFDCbBDetalheBase:EnableRowHeightVariable(FALSE)
SELFDCbBDetalheBase:Rowheight :=SELF:dOrigRowHeight // reset
rowheight to original one
SELFDCbBDetalheBase:Recalculate()
SELFDCbBDetalheBase:Refresh()
SELFDCbBDetalheBase:Recalculate()
SELFDCbBDetalheBase:SetFocus()
ENDIF
ENDIF
RETURN NIL
Hello Michael,
> Marcos, thanks for the reply. When I looked at that sample, it seemed
> that it only worked for bitmaps. Am I missing something?
Follows part of my code to display any type of image in bBrowser.
Please note that the image is saved on disk, not in a field:
[...]
FUNCTION ShowImage( cFile, nScale )
LOCAL oReturnImage AS bBitmap // bBitmap from bBrowser sample
LOCAL oImage AS FabPaintLib // graph lib from Fabrice Foray
LOCAL nHeight, nWidth AS LONG
LOCAL nNewHeight, nNewWidth AS REAL8
Default( @cFile, "" )
Default( @nScale, 1 )
IF File( cFile )
oImage := FabPaintLib{ cFile }
nHeight := oImage:Height
nWidth := oImage:Width
nNewHeight := nHeight/nScale
nNewWidth := nWidth/nScale
oImage:ResizeBilinear( nNewWidth, nNewHeight )
oReturnImage := bBitmap{ oImage:Handle(), }
ELSE
oImage := FabPaintLib{}
oImage:CreateFromResourceName( _GetInst(),"NO_IMAGE" )
oReturnImage := bBitmap{ oFabImage:Handle(), }
ENDIF
RETURN oReturnImage
[...]
HTH,
Marcos
Many thanks to both Paulo and Marcos.
Michael
On Jul 6, 10:32 am, Marcos Nogueira <marcos.nogue...@ig.com.br> wrote:
> Hello Michael,
>
> > Marcos, thanks for the reply. When I looked at that sample, it seemed
> > that it only worked for bitmaps. Am I missing something?
>
> Follows part of my code to display any type of image in bBrowser.
> Please note that the image is saved on disk, not in a field:
>
> [...]
> FUNCTION ShowImage( cFile, nScale )
>
> LOCAL oReturnImage AS bBitmap // bBitmap from bBrowser sample
> LOCAL oImage AS FabPaintLib // graph lib from Fabrice Foray
> LOCAL nHeight, nWidth AS LONG
> LOCAL nNewHeight, nNewWidth AS REAL8
>
> Default( @cFile, "" )
> Default( @nScale, 1 )
>
> IF File( cFile )
> oImage := FabPaintLib{ cFile }
> nHeight := oImage:Height
> nWidth := oImage:Width
> nNewHeight := nHeight/nScale
> nNewWidth := nWidth/nScale
> oImage:ResizeBilinear( nNewWidth, nNewHeight )
> oReturnImage := bBitmap{ oImage:Handle(), }
> ELSE
> oImage := FabPaintLib{}
> oImage:CreateFromResourceName( _GetInst(),"NO_IMAGE" )
> oReturnImage := bBitmap{ oFabImage:Handle(), }
> ENDIF
>
> RETURN oReturnImage
> [...]
>
> HTH,
>
> Marcos