HMG Graph based on Bos Taurus

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Graph based on Bas Taurus

Post by mol »

I've made a little test to find where is the problem is located.
I didn't found solution yet, but:
1. When I used Rathi's DrawGraph function in the loop, saving image to file without displaying it, after 23 regenerations images were incorrect.

Code: Select all

Function Main
	local i
	private hBitMap
	MsgInfo('Start')
	
	for i:=1 to 1000
		cfile :='images\im_'+strzero(i,4)+'.bmp'
		// first parameter for graph type, second image filename
		drawgraph(i%3 +1, cFile)
	next i
	
	msgStop('Images generated')
	quit
 return
2. When I used BosTaurus demo11.prg to generate simple bitmap:

Code: Select all

FUNCTION Proc_Create_Logo
LOCAL hDC, BTstruct
LOCAL hBitmap, hBitmap_aux 
LOCAL aRGBcolor := {153,217,234}

   // Create bitmap in memory
   hBitmap := BT_BitmapCreateNew (150, 100, aRGBcolor)

   // Create hDC to a bitmap
   hDC := BT_CreateDC (hBitmap, BT_HDC_BITMAP, @BTstruct)     
     
     // Paint Gradient
     BT_DrawGradientFillVertical (hDC,  0,  0,  150,  100, aRGBcolor, BLACK)                 
     
     // Draw Text
     nTypeText    := BT_TEXT_TRANSPARENT + BT_TEXT_BOLD    
     nAlingText   := BT_TEXT_LEFT + BT_TEXT_TOP
     nOrientation := BT_TEXT_NORMAL_ORIENTATION
     BT_DrawText (hDC, 10, 20, "HMG Casino", "Times New Roman", 14, BLACK, WHITE, nTypeText, nAlingText, nOrientation)
      
     // Draw Rectangle
     BT_DrawRectangle (hDC, 5, 5, 140, 90, BLUE, 2)

     // Paste image
     // hBitmap_aux := BT_BitmapLoadFile ("img.png") // load from disk
     hBitmap_aux := BT_BitmapLoadFile ("imgPNG")  // load from resource
        BT_DrawBitmapTransparent (hDC, 30, 30, 100, 100, BT_SCALE, hBitmap_aux, NIL)
     BT_BitmapRelease (hBitmap_aux)
  
  // Release hDC bitmap  
  BT_DeleteDC (BTstruct)   

Return hBitmap
and modified loop:

Code: Select all

	for i:=1 to 1000
		cfile :='images\im_'+strzero(i,4)+'.bmp'
		 hBitmap := Proc_Create_Logo ()
		BT_BitmapSaveFile (hBitmap, cfile)
	next i
I've got all 1000 images good.

Something is wrong with code generating bars, I think
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG Graph based on Bas Taurus

Post by Rathinagiri »

I will look into it Marek.

Instead of onchange event of the combobox if it is onlostfocus or a refresh button what happens?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Graph based on Bas Taurus

Post by mol »

There is the same problem even if I save generated graphs to file without displaying it.
I reviewed whole code of and I didn't found anything wrong :(
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG Graph based on Bas Taurus

Post by Rathinagiri »

I have found that the same code if compiled using HMG.3.4.1, it works well!

HMG IDE is also having the same problem of hanging after sometime. It worked well in HMG.3.4.1.

So, there might be a problem in the change in the code from HMG.3.4.1 to the latest version?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

mol

Post by mol »

I've made my code in last months with hmg343.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG Graph based on Bas Taurus

Post by Rathinagiri »

Can you please try in HMG3.4.2 or 3.4.1 and tell me whether the problem persists in the old version also?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Graph based on Bas Taurus

Post by mol »

HMG 342 causes problems.
Ihave not installed hmg 341, I'll try to download it and test.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Graph based on Bas Taurus

Post by mol »

I've tested with hmg 340 and hmg 341. Everything works OK.
Something was from hmg342
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG Graph based on Bas Taurus

Post by Rathinagiri »

Thank you for the confirmation Marek. Now let us find the bug.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Graph based on Bas Taurus

Post by mol »

After few regeneration of graph, I'm getting very big file with picture - something about 1GB. Creating this file causes system hangup for minutes.
It's strange because I've declared constant width and height.
I'm still testing :)

EDIT:

I've modified my program to save bitmap immediately after creating it:

Code: Select all

		nWidth := 610
		nHeight := 258
	
		hBitMap := BT_BitmapCreateNew ( nWidth, nHeight, { 196, 255, 255 } )
		BT_BitmapSaveFile (hBitmap, cfile)
First few times it generates good picture, after 7-8 calls, it generated big incorrect pictures.

I can't reproduce this error in small sample :(

It's strange behaviour, because all works OK in hmg 341, source code of BosTaurus functions bt_bmp_create_24bpp, BT_BMP_CREATE and BitmapCreateNew are the same in hmg 341 and hmg 343.

Maybe something wrong with memory allocation?
Post Reply