Adjust a Bmp to a xBrowse-Cell-Grid ?

Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby ukoenig » Thu Mar 05, 2009 3:15 pm

Hello,

is it possible, to fill a xBrowse-Cell complete with aBMP ( like a picture table ) ?
Normally at least one Char is needed.
I think it must be changed inside the class.
I would be nice, xBrowse could be used as a real picture-browser ( no text )

The color resolution of the used / tested imaged from the image-directory is very low.
Is it maybe possible to use JPG- or BMP-files with higher resolutions ?

Possible Cell-Display ?
Image

Inside the Browser it works, but doesn't fill the cell completely.
Image

There was a possible xBrowse-solution, I have done for Silvio to display images on Mouseclick inside a cell.
I can show any Backgrounds and display a Cell-Bmp on top of it.
I want to use something like that inside my own application.
For a graphic-software, I need to show small scanned portraits of students, belonging to a school-class.
With a double-click on a cell, I open a file-list from a directory with all students-pictures to select a picture.
Each class is displayed with a extra browser. For a 3D-effect, I included a xBrowse-Shadow.
The final version will have two folderpages :
1. Page the Browser
2. Page shows Detail-informations of the student of the selected cell.

The first solution ( Silvio )
Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby Jonathan Hodder » Mon Mar 09, 2009 12:52 am

Hi Uwe

Your project sounds useful for my sons school.
Just a thought...I thought BMP's can be adjusted to fit a frame.
Long time since I experimented with them.
The display of native JPG's would be better though.
I can't help at the moment, maybe someone else can help you.
When you have sorted out the problems please let me know.

Best wishes
Jonathan Hodder
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby Daniel Garcia-Gil » Mon Mar 09, 2009 5:40 am

Hello Uwe

is it possible, to fill a xBrowse-Cell complete with aBMP ( like a picture table ) ?

yes, please try with this columns data lBmpStretch and set "true"
oBrw:aCols[ 1 ]:lBmpStretch := .t.

Is it maybe possible to use JPG- or BMP-files with higher resolutions ?
yes, see my post in spanish forum
viewtopic.php?p=76565#p76565
this explain how paint jpg and other imagen format in xbrowse

With a double-click on a cell, I open a file-list from a directory with all students-pictures to select a picture.

i 'm thinking for other case, i hope have answer soon
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby ukoenig » Mon Mar 09, 2009 9:14 am

Hello Daniel,

I did some tests, but it doesn't work with other formats.
With BMP it is ok. Freeimage is included because i use a JPG-Logo on Main-Screen and that works.
Test.jpg is shown as logo on Screen for a test ( size 50 x 50 ).

hBitmap = FILoadImg( AllTrim( "Test.jpg" ) )

if Upper( cFileExt( cFile ) ) = "BMP"
return ReadBitmap( 0, cFile )
endif

67 nFormat = FIGETFILETYPE( cFile, 0 )

Application
===========
Path and name: D:\_TEST\testxbrw.exe (32 bits)
Size: 1,779,712 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 03/09/09, 10:06:26
Error description: Error BASE/1099 Argument error: STR
Args:
[ 1] = U
[ 2] = U
[ 3] = U

Stack Calls
===========
Called from: => STR(0)
Called from: .\source\classes\IMAGE.PRG => FIGETFILETYPE(0)
Called from: .\testxbrw.PRG => FILOADIMG(67)
Called from: .\testxbrw.PRG => MAIN(20)

It seems only BMP is accepted.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby Daniel Garcia-Gil » Mon Mar 09, 2009 2:56 pm

hello Uwe

do you have this line on the end of file?

please download the test

http://www.sitasoft.com/fivewin/test/testximg.rar

Code: Select all  Expand view
DLL32 FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib

DLL32 FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_Load@12" LIB hLib

DLL32 FUNCTION FIGETINFOHEADER( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetInfoHeader@4" LIB hLib

DLL32 FUNCTION CREATEDIBITMAP( hDC AS LONG, hInfoH AS LONG, nFlags AS LONG, hBits AS LONG, hInfo AS LONG, nUsage AS LONG ) AS LONG ;
      PASCAL FROM "CreateDIBitmap" LIB "gdi32.dll"

DLL32 FUNCTION FIGETINFO( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetInfo@4" LIB hLib

DLL32 FUNCTION FIGETBITS( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetBits@4" LIB hLib
     
DLL32 FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID ;
      PASCAL FROM "_FreeImage_Unload@4" LIB hLib
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby ukoenig » Mon Mar 09, 2009 3:48 pm

Hello Daniel,

I didn't include the DLL-functions, because they are defined
in class TIMAGE.prg.
I added them to the test and it works fine now.
But why do we need them to define twice ?
I still have to figure out, to display a Image without text inside a cell.
( a column with only images )
There is a new FREEIMAGE-version I tested with :
new size 2.084.864 / 27.07.2008
It works without problems.

Thank You
Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby Daniel Garcia-Gil » Mon Mar 09, 2009 3:57 pm

But why do we need them to define twice ?


i think are private function
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby ukoenig » Wed Mar 11, 2009 3:08 pm

Hello Daniel,

Your solution works fine. The basics are done, but there is still much to do.
Because in the future, I will work with a database, I added a dynamic-bmp-list.
There will be a "blanc" picture added to the array, if a picture is missing.
Each person will have a picture-number.
The picture-name in the picture-directory will be "Picture" + alltrim((database)->NO)) + ".jpg"
There will be a index on < Picture-Number > in the database, to build the array for xbrowse.

Image

Code: Select all  Expand view

#include "FiveWin.ch"
#include "xbrowse.ch"

REQUEST DBFCDX
STATIC hLib

FUNCTION MAIN()

local oDlg
local oBrw
local nI
local hBitMap := {} // Bitmap-object defined as array
local aArray:={}

for nI = 1 to 10
   aadd( aArray, { nI,;
                   "Row:"+StrZero(nI,2) + " Col: 02",;
                   "Row:"+StrZero(nI,2) + " Col: 03",;
                   "Row:"+StrZero(nI,2) + " Col: 04"} )
next

hLib := LoadLibrary( "freeimage.dll" )

// dynamic image-defines
i := 1
FOR i := 1 TO 4  // will be reccount() with a database
    xxx := LTRIM(STR(i))
    AADD( hBitmap, { "cara" + xxx + ".jpg" } )
    hBitmap[i] = FILoadImg( AllTrim( "cara" + xxx + ".jpg" ) )
NEXT

DEFINE DIALOG oDlg title "TEST" size 800,600

@ 0,0 XBROWSE oBrw OF oDlg columns {1,2,3,4};
Array aArray sizes {300,100,100,100} LINES CELL

oBrw:nMarqueeStyle := 0

// dynamic image-settings
i := 1
FOR i := 1 TO 4  // will be recount() with a database
    xxx := LTRIM(STR(i))
    oBrw:aCols[ 1 ]:AddBmpHandle( hBitmap[i] )
    oBrw:nRowHeight := nBmpHeight( hBitmap[i] ) + 2
NEXT
oBrw:aCols[ 1 ]:lBmpStretch := .t.
oBrw:aCols[ 1 ]:nWidth := 100
oBrw:aCols[ 1 ]:bBmpData := {|| oBrw:aRow[ 1 ] }

// Maybe possible, to change the image from a image-list ???
oBrw:bLClicked := { | nRow, nCol | nArrayPos := oBrw:nRowSel, msgalert(  oBrw:nAt, nArrayPos ) }             

oDlg:oClient := oBrw
   
oBrw:CreateFromCode()

ACTIVATE DIALOG oDlg CENTERED ON INIT oDlg:Resize()

FreeLibrary( hLib )

RETURN NIL

// ---------------------------

#define CBM_INIT       4
#define DIB_RGB_COLORS 0

static function FILOADIMG( cFile )

local nFormat, hDib, hInfoH, hInfo, hBits, hWnd, hDC, hBmp

if Upper( cFileExt( cFile ) ) = "BMP"
      return ReadBitmap( 0, cFile )
endif

nFormat = FIGETFILETYPE( cFile, 0 )
hDib    = FILOAD( nFormat, cFile, 0 )
hInfoH  = FIGETINFOHEADER( hDib )
hInfo   = FIGETINFO( hDib )
hBits   = FIGETBITS( hDib )
hWnd    = GETDESKTOPWINDOW()

hDC = GETDC( hWnd )

hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )

ReleaseDC( hWnd, hDC )

FIUNLOAD( hDib )

RETURN hBmp


DLL32 FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib

DLL32 FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_Load@12" LIB hLib

DLL32 FUNCTION FIGETINFOHEADER( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetInfoHeader@4" LIB hLib

DLL32 FUNCTION CREATEDIBITMAP( hDC AS LONG, hInfoH AS LONG, nFlags AS LONG, hBits AS LONG, hInfo AS LONG, nUsage AS LONG ) AS LONG ;
      PASCAL FROM "CreateDIBitmap" LIB "gdi32.dll"

DLL32 FUNCTION FIGETINFO( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetInfo@4" LIB hLib

DLL32 FUNCTION FIGETBITS( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetBits@4" LIB hLib
     
DLL32 FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID ;
      PASCAL FROM "_FreeImage_Unload@4" LIB hLib

 


Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Adjust a Bmp to a xBrowse-Cell-Grid ?

Postby Jonathan Hodder » Thu Mar 12, 2009 2:06 am

Hi Uwe

Looks promising,

With a double-click on a cell, I open a file-list from a directory with all students-pictures to select a picture.

Possibly a drag and drop!

There will be a index on < Picture-Number > in the database, to build the array for xbrowse.

Do you intend to rename the <Picture-Number>?
What about date the picture was taken - cameras automatically allocate a number to the next picture taken.
Maybe the picture directory name will contain the year.
An option is to index on the data file - Student Class - and have a field in this student data
file containing the <Picture-Number> to fill the array.

Useful stuff.

Jonathan
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests