Prev: TCP/IP session - can someone help
Next: News from GrafXsoft
From: Tom Szabo on 22 Nov 2008 18:47 Hi, Does any have a sample showing how to display a JPG picture in a BBrowser cell? I had a look at the Bitmap one in the VO sample but did not get very far. TIA, Tom
From: Kevin on 23 Nov 2008 12:26 Tom Szabo wrote: Tom, Below is some code which hopefully be of use to you. It is designed to use an array server but should get you started. The code is designed to use thumbnails, creating them if needed. Hope this helps. Kevin METHOD DrawValue(oEvent) CLASS winImageWindow LOCAL uValue AS USUAL LOCAL srcArea AS _winRect LOCAL oFabImage AS FabPaintLib uValue := oEvent:Value IF IsInstanceOfUsual( uValue, #FabPaintLib) oFabImage := uValue srcArea := oEvent:Area oFabImage:ShowExDC( oEvent:DeviceContext,; srcArea.Left, srcArea.Top ) ENDIF RETURN TRUE METHOD GetImage( oServer ) CLASS winImageWindow // // Create thumbnail for viewing // LOCAL oFabImage AS FabPaintLib LOCAL cFileName AS STRING LOCAL cThumbNailName AS STRING LOCAL nHeight, nWidth, nNewHeight, nNewWidth AS LONG LOCAL nMaxDim, r8Scalefactor AS REAL8 // compose thumbnail (has to be prefixed uniquely, so that other // bBrowsers can also show images without confusing with these thumbnails // cThumbDir is directory where thumbnails are to be found // sExt is extension to be added to file name // Create path to source image cThumbNailName := self:cThumbDir + AllTrim(oServer:AGENTSN) + self:sExt//'.jpg' // Check if thumbnail already exists IF File(cThumbNailName) // if exists it then use it oFabImage := FabPaintLib{cThumbNailName, SELF} ELSE // thumbnail does not exist so create it // Look in soiurce folder for imge cFileName := self:cSourceDir + AllTrim( oServer:AGENTSN ) + self:sExt// ".jpg" oFabImage := FabPaintLib{ cFileName, SELF } // Resize image to desired dimensions if created IF oFabImage:IsValid nHeight := oFabImage:Height nWidth := oFabImage:Width nMaxDim := Max(nHeight, nWidth) // determine biggest dimension // determine scale factor based onm size 100 pixels r8Scalefactor := 100/nMaxDim nNewHeight := Integer( Round( nHeight * r8Scalefactor, 0)) nNewWidth := Integer( Round( nWidth * r8Scalefactor, 0)) oFabImage:ResizeBilinear( nNewWidth, nNewHeight) // transform to 32bpp oFabImage:SaveAsJPEG( cThumbNailName ) //oFabImage:SaveAsTIFF( cThumbNailName ) ENDIF ENDIF RETURN oFabImage METHOD LoadDB() CLASS winImageWindow // // Load Data // LOCAL aData as ARRAY local dwRecs as dword local dwCur as dword self:sExt := ".bmp" self:cSourceDir := "e:\vo28projects\bmp\" aData := {; {"FirstName", "Surname", "agentsn", "e:\vo28projects\bmp\agentsn.bmp"},; } // Get nuumber of records dwRecs := ALen( aData ) // Loop through and add to DB for dwCur := 1 upto dwRecs if oServer:Append() oServer:FIELDPUT( 'FirstName', aData[ dwCur, 1 ] ) oServer:FIELDPUT( 'Surname', aData[ dwCur, 2 ]) oServer:FIELDPUT( 'AgentSN', aData[ dwCur, 3 ]) oServer:FIELDPUT( 'PictPath', aData[ dwCur, 4 ]) endif next self:oServer:GoTop() RETURN nil METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS winImageWindow //Put your PostInit additions here self:cThumbDir := 'e:\vo28projects\thumbs\' self:SetupDatabase() self:LoadDB() SELF:SetupBrowser() RETURN NIL METHOD SetupBrowser() CLASS winImageWindow // // Setup browser // LOCAL oColumn AS bDataColumn self:oDCbrwBrowser:Use( self:oServer, {'Surname', "FirstName", "AgentSN"} ) // Set up virtual column oColumn := bDataColumn{ SELF:oDCbrwBrowser,; // owner SELF:oServer,; // Server {|Server, arg| arg:GetImage(Server)},; // Expression #Expression,; // symFieldMode SELF} // argument --> Self:GetImage() // Create and add image column oColumn:Caption := "Photo" oColumn:HyperLabel := HyperLabel{#PHOTO} oColumn:ValType := "O" oColumn:Alignment := BALIGN_CENTER oColumn:Width := 100 // 100 pixels width oColumn:Resizable := FALSE SELF:oDCbrwBrowser:AddColumn( oColumn ) SELF:oDCbrwBrowser:OpenColumn( oColumn, 1 ) // make it first column self:oDCbrwBrowser:RowHeight := 100 //self:oDCbrwBrowser:Grid := bGrid{BGRID_OUTLINE} SELF:oDCbrwBrowser:Recalculate() SELF:oDCbrwBrowser:Refresh() RETURN NIL METHOD SetupDatabase() CLASS winImageWindow // // Setup data array // LOCAL aDBStruc as ARRAY LOCAL aData as ARRAY aData := {} aDBStruc := {; { 'FirstName', 'C', 30, 0},; { 'Surname', 'C', 30, 0},; { 'AgentSN', 'C', 25, 0},; { 'PictPath', 'C', 255, 0}; } self:oServer := bArrayServer{ aDBStruc, aData } self:oServer:CreateOrder( "Server:SURNAME+Server:SURNAME") self:oServer:CreateOrder( "Server:AGENTSN" ) self:oServer:SetOrder( 2 ) self:oServer:GoTop() RETURN nil > Hi, > > Does any have a sample showing how to display a JPG picture in a > BBrowser cell? > > I had a look at the Bitmap one in the VO sample but did not get very > far. > > TIA, > > Tom --
From: Geoff Schaller on 23 Nov 2008 16:26 Tom, One of the main factors is performance. You have to be careful. The natural design of bBrowser is that it keeps a buffer of rows that grows as you scroll and all those cells are constantly being re-read. More often than you suspect. If there is code that is executed on cell refresh you need to keep this in mind. And then there is the grid. All the visible cells are repainted on every screen refresh (which can be many times a minute - several a second during certain events). If this involves building files and reloading bitmaps converting to jpg you may have to think the design very carefully. Geoff "Tom Szabo" <tom(a)intersoft.net.au> wrote in message news:49289a27$1(a)dnews.tpgi.com.au: > Hi, > > Does any have a sample showing how to display a JPG picture in a BBrowser > cell? > > I had a look at the Bitmap one in the VO sample but did not get very far. > > TIA, > > Tom __________ Information from ESET NOD32 Antivirus, version of virus signature database 3632 (20081121) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
|
Pages: 1 Prev: TCP/IP session - can someone help Next: News from GrafXsoft |