DC_BitmapDraw()

This forum is for eXpress++ general support.
Message
Author
User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

DC_BitmapDraw()

#1 Post 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

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_BitmapDraw()

#2 Post by rdonnay »

I need more information.

Send me a sample program that shows the problem.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: DC_BitmapDraw()

#3 Post 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

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_BitmapDraw()

#4 Post 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')
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: DC_BitmapDraw()

#5 Post 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.

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_BitmapDraw()

#6 Post 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?
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: DC_BitmapDraw()

#7 Post by unixkd »

Yes

That feature enables us to display pictures of different sizes on a DCBITMAP static

Thanks

Joe

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DC_BitmapDraw()

#8 Post 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
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: DC_BitmapDraw()

#9 Post by unixkd »

Thanks Roger

Exactly what I want.

Joe

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: DC_BitmapDraw()

#10 Post by unixkd »

Hi Roger

DCSTATIC ... does not have :autoScale property, only :autoSize and they do not behave the sameway

Thanks.

Joe

Post Reply