GTWVG - imagem proporcional - help

689 views
Skip to first unread message

Sami Laham

unread,
Feb 15, 2013, 8:37:55 AM2/15/13
to harbou...@googlegroups.com

Hello friends, I'm trying to get pictures with gtwvg but I would put images without distortion, images proportional

someone has an example to share?

 

I am using to display the images.

 

Wvt_DrawImage (14, 10, 18, 30,. "\ JPG100 \ 006010.jpg")

 

I know that changing the coordinates changes the proportions.

 

 

Best regards

 

Sami Laham



 

elch

unread,
Feb 16, 2013, 5:52:53 AM2/16/13
to harbou...@googlegroups.com, sami-...@laham.com.br
Hi Sami,

look down here in entry: gfx_bitmap() some days ago. Don't be disturbed by Linux in the topic, it's also done for gtwvg.
I post there an example to resize the image with help of freeimage (hbfimage) lib, saving the result to a tempfile.
In this i'm stretching the image to the ! text ! coordinates i want - and so this WVT_DRAWIMAGE() will do.

So i see there two solutions for you:
* resize the image to text coordinates  nearby  the wanted ones, without leaving the original proportion.
You must do a little calculation, search for the more x or y of image, calculate the scale faktor for window, and use this for scaling both x and y.
Afterwards you know the size of the result and can calculate/ transmit the resulting text coordinates to WVT_DRAWIMAGE().

THIS seem a quick and compareable easy solution for you, which should work ok. You will have just a dis-proportion of some pixels wide.


* further there exists a nearly secret FI_WINDRAW() in the freeimage wrapper code, which accept pixel coordinates for displaying.
Here we also have to resize image before displaying like in example above - without needing a tempfile.
BUT ! i have had problems to fetch the drawing context with WVG_GETDC(), which is needed as second par - at least in gtwvt.
AND BUT NEXT the pixel coordinates seem relative to the whole desktop screen, so we need the upper left coordinates of our window for calculation.
But actually gtwvg version doesn't return them with: hb_gtinfo( HB_GTI_SETPOS_XY ).
I posted a fix suggest in Harbour devel list with topic:
"gtwvg - very minor changes"

THIS seem complicate and much to do for you, a compile of Harbour is needed at least.

##
NICE, i'm not alone in MilkyWay who want to display graphics :-)

regards
Rolf

elch

unread,
Feb 16, 2013, 5:42:59 PM2/16/13
to harbou...@googlegroups.com
hi again, Sami

if i push my faulty english through goggel translate ... please ask again if you don't understand something what i try to tell to you.
I also wish to hear new impressions for myself.

regards
Rolf

Sami Laham

unread,
Feb 16, 2013, 7:38:01 PM2/16/13
to harbou...@googlegroups.com
Hi Rolf first of all  thanks for replying, do not worry about my English is also "by google" I understand perfectly what you suggested, was what I was thinking of doing, I downloaded your "preview.prg" and took a look at your source is I'm even looking.
I'll do some testing here, Wvt_DrawImage has a second set of Paramenters to resize the image  "{4, 4, -4, -4}" within the rows and columns, so I'm thinking of doing this without generating the file temporary in FreeImage just get the image size and do the calculations and adjust it in second parameter. Your example will help me a lot.

  Wvt_DrawImage (:: Ntop, :: nLeft, :: nBottom, :: nRight, :: cFileImage, {4, 4, -4, -4})

I'll do the tests and if get good I will put an example here. after all we are not the only ones in the Milky Way that use images :).

Regards

Sami Laham

elch

unread,
Feb 17, 2013, 2:46:39 AM2/17/13
to harbou...@googlegroups.com

HI Sami, nice to hear from you


i speak a bit english - enough to buy bread and eggs ;-) - i mean if i let goggel translate it back to my mother language, i don't understand myself.


--

I am working with a nice small RAM drive for this tempfile. This means a filesystem not on real disk, but in RAM.

In Linux it is just an entry in /etc/fstab, and there also exist solutions in Windows, i have one.

So creating a tempfile on a RAM drive is nearly the same as to fetch the result from any function. It fly quickly like a meteor ...


I very intensive use this freeimage lib, at much other occasions - f.e. when creating pdf with images - could save my life as developer.


###

That are feedbacks i searching for:

wvt_drawimage() have more parameters than my poor one know ?!! - nice to hear that.

And i need graphics display more for Linux than Windows, as special solution ...


regards

Rolf

elch

unread,
Feb 26, 2013, 7:21:24 PM2/26/13
to harbou...@googlegroups.com
Hi Samy,

you deleted my Linux Version in your direct feedback :-)
That was the much more research work - and very sure ok, you perhaps don't need that.

I like to integrate that myself new learned, in my demo with a switch-able max stretched, correct scaled or original sized image preview. Perhaps, if i have a bit time left from real work ..

---
But two further hints:
we seem need to write at application start:
IF HB_GtVersion() == "WVG"
Wvt_SetGui( .T. )
ENDIF

else these drawn graphics are not persistent. This means you can take another window and use it as a cleaning rag.
With this other window over our you can wipe the drawn graphics away. Setting above bewares this -- as far as i experienced.

Second:
a very often mistake, i see in calculation of image width:
10 - 5 = 5
mathematical correct !
but a picture from coordinate x=5 up to x=10
is six! pixels wide, where: right - left = 5
Often seen, you are not the first one. This can lead to unexpected glitches.

Regards
Rolf

Sami Laham

unread,
Mar 18, 2013, 3:13:26 PM3/18/13
to harbou...@googlegroups.com

Hello Rolf, sorry for the delay in replying but just saw your reply today when I was looking at the list of the users-group.

 

 

IF HB_GtVersion() == "WVG"
      Wvt_SetGui( .T. )     
ENDIF

 

  this was exactly what was needed to stay cool. tks

 

 

Second:
a very often mistake, i see in calculation of image width:
10 - 5 = 5
mathematical correct !
but a picture from coordinate x=5 up to x=10
is six! pixels wide, where: right - left = 5
Often seen, you are not the first one. This can lead to unexpected glitches.

You are correct good observation. :-)

 


Regards

 

Sami Laham

 

 


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
 
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nenad Batoćanin

unread,
Mar 26, 2013, 12:47:59 PM3/26/13
to harbou...@googlegroups.com, sami-...@laham.com.br
Hello! 

One simple question: how to make a minimal gtwvt program that displays a picture? For example:

PROGRAM Main
   Wvt_DrawImage (8,62,12,69,"c:\tmp\logo.bmp")
RETURN

The program crashes with a GPF.

Regards, NB

Massimo Belgrano

unread,
Mar 26, 2013, 1:39:41 PM3/26/13
to harbou...@googlegroups.com
Here a good way for learn on gtwvg

http://www.elektrosoft.it/tutorials/gtwvg/gtwvg.asp

PROCEDURE Main()

   LOCAL aPaint

   Wvt_SetGui( .T. )

   SetMode( 25, 80 )
   SetColor( "N/W" )
   CLS

   Wvt_SetTitle( "Giovanni's Window" )

   aPaint := {}
   AAdd( aPaint, { NIL , { || Wvt_DrawImage( 2, 12, 10, 23, "giovanni.jpg" ) }   , NIL } )
   AAdd( aPaint, { NIL , { || Wvt_DrawImage( 2, 45, 18, 67, "giovanni.jpg" ) }   , NIL } )
   WvtSetPaint( aPaint )

   @ 23, 0
   WAIT

   RETURN

FUNCTION Wvt_Paint()

   WvtPaintObjects()

   RETURN NIL


2013/3/26 Nenad Batoćanin <nbato...@wings.rs>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users
>  
> ---
> You received this message because you are subscribed to the Google Groups "Harbour Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  




--
Massimo Belgrano
Delta Informatica S.r.l. (http://www.deltain.it/mbelgrano)

elch

unread,
Mar 26, 2013, 1:54:56 PM3/26/13
to harbou...@googlegroups.com, sami-...@laham.com.br

Hi Nenad,



One simple question: how to make a minimal gtwvt program that displays a picture? For example:

one simple answer: not with GTWVT.


Regards

Rolf


"José M. C. Quintas"

unread,
Mar 26, 2013, 2:07:06 PM3/26/13
to harbou...@googlegroups.com
1) Create gtwvg window
2) Draw picture
3) wait

PROCEDURE Main
CLS
Wvt_DrawImage( 8, 62, 12, 69, "c:\tmp\logo.bmp" )
WAIT
RETURN

José M. C. Quintas
> -

"José M. C. Quintas"

unread,
Mar 26, 2013, 2:16:56 PM3/26/13
to harbou...@googlegroups.com
My example is for gtwvg.

Compile using:
hbmk2 teste gtwvg.hbc

José M. C. Quintas

Nenad Batocanin

unread,
Mar 26, 2013, 10:17:25 PM3/26/13
to harbou...@googlegroups.com

Thanks Massimo!

 

I read your tutorial, but it seems that my problem is wrong hbmk script.

 

Regards, NB

Nenad Batoćanin

unread,
Mar 26, 2013, 10:51:39 PM3/26/13
to harbou...@googlegroups.com, sami-...@laham.com.br
You recomend gtvvg or something else? 

NB

Nenad Batoćanin

unread,
Mar 26, 2013, 11:03:54 PM3/26/13
to harbou...@googlegroups.com
Thank you! 

My error, I've include both gt drivers. I prefer to use gtvvt due to some problems with gtvvg (eg hb_gtInfo (HB_GTI_SETPOS_XY) returns nil??). But I need Wvt_GetWindowHandle function, so I put gtvvg AND gtvvt in script. In this case gtvvg calls do not work.

Btw, I'm a little confused - why gtvvg functions have a Wvt_ prefix?

Regards, NB

elch

unread,
Mar 27, 2013, 12:06:25 AM3/27/13
to harbou...@googlegroups.com

Hi Nenad,


the problem of SETPOS_XY is known - and in a first but wrong patch from me 'corrected' in nightly version:

I should post a really corrected one, but are ashamed of my first wrong one, so i like to stay quiet.


There seem no alternative to GTWVG for reliable display bitmaps for Windows.

Joses' example misses an important point discussed earlier in this thread.


Because GTWVG is derived from GTWVT some function names seem to have the prefix wvt_.


I see no Wvt_GetWindowHandle() for GTWVT - wherfore do you need that ?


Regards

Rolf

Nenad Batocanin

unread,
Mar 27, 2013, 9:40:05 AM3/27/13
to harbou...@googlegroups.com

I use gtwvt because it has a little better quality of display fonts. Function GetWindowsHandle is used to select the folder:

 

oShell := Win_OleCreateObject ("Shell.Application")

oItem  := oShell:BrowseForFolder (Wvt_GetWindowHandle(), "Chose dir", 0, "")

 

Regards, NB

 

From: harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On Behalf Of elch
Sent: Wednesday, March 27, 2013 5:06 AM
To: harbou...@googlegroups.com
Subject: Re: [harbour-users] Re: GTWVG - imagem proporcional - help

 

Hi Nenad,

--

"José M. C. Quintas"

unread,
Mar 27, 2013, 11:57:12 AM3/27/13
to harbou...@googlegroups.com
If the only reason to not use gtwvg is font, then change font:

#include "hbgtinfo.ch"
PROCEDURE Main
   SetMode( 24, 80 )
   CLS
   hb_GtInfo( HB_GTI_FONTNAME, "Lucida Console" )
   FOR nCont = 1 TO MaxRow()
      ? Replicate( Chr( nCont+64), MaxCol() )
   NEXT
   Inkey(0)

   RETURN

José M. C. Quintas



Nenad Batocanin

unread,
Mar 27, 2013, 2:41:32 PM3/27/13
to harbou...@googlegroups.com

I use the same font in both cases. With the same parameters (font, size, quality, palette…) gtvvg looks a worse than the gtvvt.

 

Regards, NB

gtwvt.jpg
gtwvg.jpg

Pritpal Bedi

unread,
Mar 28, 2013, 3:22:38 PM3/28/13
to harbou...@googlegroups.com, sami-...@laham.com.br
Hi Sami



Hello friends, I'm trying to get pictures with gtwvg but I would put images without distortion, images proportional


Dowload latest Harbour, no revision nos please.

Wvt_DrawImage( nRow, nCol, nToRow, nToCol, cImage, aPxlOff, lDoNotScale )

By default <lDoNotScale> == FALSE to preserve existing functionality.


Pritpal Bedi

Pritpal Bedi

unread,
Mar 28, 2013, 3:28:04 PM3/28/13
to harbou...@googlegroups.com
Hi Nenad



I use the same font in both cases. With the same parameters (font, size, quality, palette…) gtvvg looks a worse than the gtvvt.


GTWVG has slight differences in couple of colors from GTWVT.
Like in your images BLUE as in "W+/b" and WHITE as in "N/W" only.
There is no difference in fonts.

BTW, you can achieve exact same colors as in GTWVT by a single call 
at the top of any GT specific call is made, with Wvt_SetPalette() function.

So it is a matter of personal taste.

If used as pure console, there are only few differences in both GTs.
But if you intend to enhance your apps with GUI look and feel, GTWVT will not help.


Pritpal Bedi

Nenad Batocanin

unread,
Mar 28, 2013, 7:46:52 PM3/28/13
to harbou...@googlegroups.com

Thanks for me, also :)

 

Can you please explain parameter aPxlOff?

 

Regards, NB

--

Pritpal Bedi

unread,
Mar 28, 2013, 7:55:28 PM3/28/13
to harbou...@googlegroups.com
Hi


Can you please explain parameter aPxlOff?


Wvt_DrawImage( nRow, nCol, nToRow, nToCol, cImageFile, aPixOff, lDoNotScale )

<aPixOff> { 4,4,-4,-4 } => Top,Left,Bottom,Right offset in pixels from the rectangle 
obtained from { nRow, nCol, nToRow, nToCol }. 

So if aPixOff == { 4,4,-2,-2 } then picture rectangle calculated with row/col coordinates
will be adjusted by the relevant pixels contained in the array.

Note that one row can contain as many pixels its font points to.

Hope it is clear by now.


Pritpal Bedi
a student of software analysis & concepts

Nenad Batocanin

unread,
Mar 28, 2013, 8:01:12 PM3/28/13
to harbou...@googlegroups.com

I think the problem is not in color, edges of the letters are different (see larger image). All parameters are controlled by the user, it performs the following initialization:

 

HB_GtInfo (HB_GTI_ISFULLSCREEN, lFull)

HB_GtInfo (HB_GTI_FONTNAME, cFont)

HB_GtInfo (HB_GTI_FONTWIDTH, nW)

HB_GtInfo (HB_GTI_FONTSIZE , nH)

HB_GTInfo (HB_GTI_FONTQUALITY, nFQ)

HB_GTInfo (HB_GTI_FONTWEIGHT, nFW)

HB_GTInfo (HB_GTI_PALETTE, aPal)

IF aWnd <> NIL

   HB_GtInfo (HB_GTI_SETPOS_XY, aWnd)

END IF

 

It is the exactly the same for both cases. First I used the gtwvg, but users have complained about the look, so I had to move to gtwvt. I plan to use hbqt, gtvvt is only a temporary solution.

 

Ragards, NB

 

From: harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On Behalf Of Pritpal Bedi
Sent: Thursday, March 28, 2013 8:28 PM
To: harbou...@googlegroups.com
Subject: Re: [harbour-users] Re: GTWVG - imagem proporcional - help

 

Hi Nenad

--

vt.jpg
vg.jpg

Pritpal Bedi

unread,
Mar 28, 2013, 8:08:05 PM3/28/13
to harbou...@googlegroups.com
Hi


I think the problem is not in color, edges of the letters are different (see larger image). All parameters are controlled by the user, it performs the following initialization:

 

HB_GtInfo (HB_GTI_ISFULLSCREEN, lFull)

HB_GtInfo (HB_GTI_FONTNAME, cFont)

HB_GtInfo (HB_GTI_FONTWIDTH, nW)

HB_GtInfo (HB_GTI_FONTSIZE , nH)

HB_GTInfo (HB_GTI_FONTQUALITY, nFQ)

HB_GTInfo (HB_GTI_FONTWEIGHT, nFW)

HB_GTInfo (HB_GTI_PALETTE, aPal)

IF aWnd <> NIL

   HB_GtInfo (HB_GTI_SETPOS_XY, aWnd)

END IF


For GTWVG try as 
Wvt_SetFont( cFont, nHeight, nWidth, nQuality ) -> aOldFontInfo
Font propogation in GTWVT, if I have not already fixed, is a little ambigous.

  

It is the exactly the same for both cases. First I used the gtwvg, but users have complained about the look, so I had to move to gtwvt. I plan to use hbqt, gtvvt is only a temporary solution.


Yep, that is the future.

BTW, if you are not thinking of adding GUI components to 
your application then you can always stay with GTWVT. 


Pritpal Bedi

Nenad Batocanin

unread,
Mar 28, 2013, 8:58:01 PM3/28/13
to harbou...@googlegroups.com

Hope it is clear by now.

 

Yes, thanks

 

NB

Nenad Batocanin

unread,
Mar 28, 2013, 8:58:36 PM3/28/13
to harbou...@googlegroups.com

For GTWVG try as 

Wvt_SetFont( cFont, nHeight, nWidth, nQuality ) -> aOldFontInfo

Font propogation in GTWVT, if I have not already fixed, is a little ambigous.

 

Thanks, I'll try

  

 

 

 

BTW, if you are not thinking of adding GUI components to 

your application then you can always stay with GTWVT. 

 

For now I'm satisfied with gtwvt. Now I need a simple slideshow, so I tried to activate gtwvg. Maybe I'll use hbqt (see Dusan Majkić question).

 

Regards, NB

Sami Laham

unread,
Apr 1, 2013, 8:36:09 AM4/1/13
to harbou...@googlegroups.com

Hi Pritpal, thanks for the new improvement. I will test.

Do you know if the "Harbour nightly build"  is update with this last changes ?

 

Regards,

Sami Laham

 


--

--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
 
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nenhum vírus encontrado nessa mensagem.
Verificado por AVG - www.avgbrasil.com.br
Versão: 2013.0.2904 / Banco de dados de vírus: 2641/6210 - Data de Lançamento: 03/28/13

Sami Laham

unread,
Apr 1, 2013, 9:02:23 AM4/1/13
to harbou...@googlegroups.com

Hi Pritpal, forget my last question, i need download on Git and build. 

 

Regards,  

 

Sami


Versão: 2013.0.2904 / Banco de dados de vírus: 2641/6218 - Data de Lançamento: 04/01/13

Reply all
Reply to author
Forward
0 new messages