Page 1 of 2
DC_BitmapDraw()
Posted: Wed Jul 15, 2015 5:42 am
by unixkd
Hi Roger,
The image draw on the Static object dissapear when an MDI dialog is resized or moved off the screen.
I use express 259.
Thanks.
Joe
Re: DC_BitmapDraw()
Posted: Wed Jul 15, 2015 6:36 am
by rdonnay
I need more information.
Send me a sample program that shows the problem.
Re: DC_BitmapDraw()
Posted: Fri Jul 24, 2015 4:22 am
by unixkd
Here is the sample program:
Function Main()
LOCAL GetList[0], GetOptions
Local oDirs, cGraphicFileDir, oFiles, cBitMapFile, oBitMap, oPhotoStatic, oPhoto, c_Photo
Local bBmpFileName := {|cDir,oFile|/*DC_Arrayview(cDir),*/ "\"+curDir()+"\"+oFile:FileList:GetItem(oFile:FileList:GetData()[1])}
@ 0,0 DCDIRTREE COLOR GRA_CLR_BLACK, GRA_CLR_WHITE ;
DIRS oDirs VAR cGraphicFileDir ;
FILES oFiles VAR cBitMapFile ;
SIZE 60, 20 ;
EXT "*.JPG","*.BMP","*.PCX","*.GIF","*.PNG","*.EMF", "*.BMP *.JPG *.PNG *.GIF *.EMF *.PCX" ,"*.*" ;
EVAL {|o| o:FileList:ItemMarked := {|| oBitMap := DC_GetBitMap(Eval(bBmpFileName,cGraphicFileDir,oFiles)), DC_BitMapDraw(oPhotoStatic,oBitMap)}}
@ 0,65 DCSTATIC TYPE XBPSTATIC_TYPE_RAISEDBOX SIZE 25,8 OBJECT oPhotoStatic
DCBITMAP c_Photo OBJECT oPhoto AUTOSCALE CENTER PARENT oPhotoStatic
DCGETOPTIONS RESIZE RESIZEDEFAULT DCGUI_RESIZE_AUTORESIZE
DCREAD GUI FIT TITLE 'Photo Capture Routine' OPTIONS GetOptions ADDBUTTONS
Return nil
*
PROC appsys ; RETURN
*
1. Move the dialog off the screen OR resize it and see the bitmap disappear
2. Copy the bitmaps to the application directory
3. cGraphicFileDir and cBitMapFile are not updated when you navigate the tree
4. Uncomment the DC_Arrayview in the program to see that it always return nil
Thanks.
Joe
Re: DC_BitmapDraw()
Posted: Fri Jul 24, 2015 5:07 am
by rdonnay
This is no longer the recommended method of painting a bitmap.
This technique of drawing a DCBITMAP on a DCSTATIC is an early feature of eXpress++ that was put in there because there was no other way until Alaska improved Xbase++ with later releases.
It requires a :paint callback to make sure that the bitmap gets repainted.
Rather than tell you how to do that, I suggest another solution:
@ nRow, nCol DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP CAPTION DC_GetBitmap('..\bitmaps\bitmap1.jpg')
Re: DC_BitmapDraw()
Posted: Thu Jul 30, 2015 6:27 am
by unixkd
Hi Roger
Thanks for your suggestion. Work well.
1. I need to display image stored in a BLOB field.
2. I need to implement the AUTOSCALE feature of DCBITMAP in the DCSTATIC object.
Joe.
Re: DC_BitmapDraw()
Posted: Thu Jul 30, 2015 7:02 am
by rdonnay
1. I need to display image stored in a BLOB field.
2. I need to implement the AUTOSCALE feature of DCBITMAP in the DCSTATIC object.
Are you asking how to do this?
Re: DC_BitmapDraw()
Posted: Thu Jul 30, 2015 7:08 am
by unixkd
Yes
That feature enables us to display pictures of different sizes on a DCBITMAP static
Thanks
Joe
Re: DC_BitmapDraw()
Posted: Thu Jul 30, 2015 8:54 am
by rdonnay
Alaska gives an example of how to load an XbpBitMap() object from a Foxpro blob field.
Run the sample .\source\samples\basics\dbbmp\animate.exe
Here is eXpress++ code that does essentially the same thing.
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main()
LOCAL GetList[0], oStatic, oBitmap
DbeLoad("FOXDBE",.F.)
DbeSetDefault("FOXDBE")
SET DEFAULT TO C:\users\rd\documents\xbase++\source\samples\data\misc
USE bmpdb
oBitmap:= XbpBitmap():new():create()
oBitmap:setBuffer(BMPDB->bitmap,XBPBMP_FORMAT_WIN3X)
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP SIZE 800, 600 PIXEL ;
CAPTION oBitmap EVAL {|o|o:autoScale := .t.} ;
OBJECT oStatic
DCREAD GUI FIT TITLE 'Animation Demo' ;
EVAL {||RunAnimation(oStatic,oBitmap)}
RETURN nil
* -----------
PROC appsys ; RETURN
* -----------
FUNCTION RunAnimation(oStatic,oBitmap)
BMPDB->(dbGoTop())
DO WHILE !BMPDB->(Eof())
oBitmap:setBuffer(BMPDB->bitmap,XBPBMP_FORMAT_WIN3X)
oStatic:configure() // <<<<<<<<<<<<< this autosizes the bitmap
BMPDB->(dbSkip())
Sleep(5)
ENDDO
RETURN nil
Re: DC_BitmapDraw()
Posted: Thu Jul 30, 2015 1:47 pm
by unixkd
Thanks Roger
Exactly what I want.
Joe
Re: DC_BitmapDraw()
Posted: Fri Jul 31, 2015 12:29 am
by unixkd
Hi Roger
DCSTATIC ... does not have :autoScale property, only :autoSize and they do not behave the sameway
Thanks.
Joe