change the size of a bitmap

change the size of a bitmap

Postby Silvio » Sun Aug 09, 2009 4:42 pm

If I define on init a bitmap with :

#define BMP_H 40
#define BMP_V 40

and then on my application make bitmaps with this size

For nX := 1 To TOTX
@ nrow, ncol BITMAP aBmps[ nY, nX ] RESOURCE "VUOTO" OF oDlg;
SIZE BMP_H, BMP_V PIXEL ADJUST NOBORDER
ncol:=ncol+BMP_V
Next nX

If I want chage the size from user
How I can make ?
sample:



#define BMP_H 40
#define BMP_V 40

function config()
Local odlgconfig, lsave,oBtn
Local oGet[2]
Local nBMP_H := BMP_H
Local nBMP_V := BMP_V



DEFINE DIALOG oDlgConfig TITLE "Configurazione griglia" ;
FROM 2, 2 TO 13, 40

@ 10, 5 say "File :" SIZE 40, 13 pixel OF oDlgConfig
@ 30, 5 say "Colonne :" SIZE 40, 13 pixel OF oDlgConfig

@ 10, 30 GET nBMP_H VAR oGet[1] SIZE 40, 13 pixel OF oDlgConfig

@ 30, 30 GET nBMP_V VAR oGet[2] SIZE 40, 13 pixel OF oDlgConfig


@ 3, 4 BUTTON oBtn PROMPT "&Ok" SIZE 45, 12 OF oDlgConfig ;
ACTION ( oDlgConfig:End(), lsave:=.t. ) DEFAULT

@ 3, 14 BUTTON "&Cancel" SIZE 45, 12 OF oDlgConfig ;
ACTION ( oDlgConfig:End(), lsave:=.f. )


ACTIVATE DIALOG oDlgConfig CENTERED

* BMP_H := nBMP_H
* BMP_V := nBMP_V
RETURN NIL


First
Why I cannot write into the get ?

Second
then How I refresh a defined variable ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: change the size of a bitmap

Postby ukoenig » Sun Aug 09, 2009 5:12 pm

Hello Sylvio,

Code: Select all  Expand view

For nX := 1 To TOTX
     aBmp[ nY, nX ]:nWidth() := nHORZ // new Value
     aBmp[ nY, nX ]:nHeight() := nVERT // new Value
     aBmp[ nY, nX ]:Refresh()
Next nX
 


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: change the size of a bitmap

Postby Silvio » Sun Aug 09, 2009 5:30 pm

Uwe I try it but then all bitmaps are moved look it please

First

Image



then

Image

this is the function :
Code: Select all  Expand view
#define ZOOM_H    5
#define ZOOM_V    5

STATIC  function ZoomIn()
  Local nY, nX
  lOCAL nRow
  Local nCol
  local nNewHeigth
  local nBottom
  local nRight

  nRow := aBmps[ 1, 1 ]:nTop
  nCol := aBmps[ 1, 1 ]:nLeft
  nBottom := aBmps[ 1, 1 ]:nBottom
  nRight := aBmps[ 1, 1 ]:nRight

For nY := 1 to TOTY
  For nX := 1 To TOTX
    aBmps[ nY, nX ]:nTop := nRow
    aBmps[ nY, nX ]:nLeft := nCol
    aBmps[ nY, nX ]:nWidth  += ZOOM_V
    aBmps[ nY, nX ]:nHeight += ZOOM_H
    ncol += aBmps[ nY, nX ]:nWidth +ZOOM_V
    nNewHeigth := aBmps[ nY, nX ]:nHeight +ZOOM_H
  Next nX
  nCol := 0
  nRow += nNewHeigth
Next nY

   aBmps[ nY, nX ]:refresh()

return nil
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: change the size of a bitmap

Postby ukoenig » Sun Aug 09, 2009 6:04 pm

Silvio,

I had a look at Your Screenshots,
There is a defined Gridsize ( Position Left, Upper ) where You paint the BMP's.
In case You change the Size of the BMP, the Grid must be adjusted as well, before the new BMP
is painted with a new Size.
If You don't resize the Grid, the BMP's are shown interleaved, because the Left- Upper-Position of the BMP is defined in Relation to the Grid.
That means, at first the Grid-Size must be changed ( zoomed ) to the new Size.

Best Regards
Uwe :lol:
Last edited by ukoenig on Sun Aug 09, 2009 10:18 pm, edited 1 time in total.
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: change the size of a bitmap

Postby Silvio » Sun Aug 09, 2009 9:46 pm

there is none grid !!
they are all bitmaps ....!!!!!
I you see a grid is only a eye game
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: change the size of a bitmap

Postby James Bott » Sun Aug 09, 2009 10:19 pm

What Uwe is saying is still somewhat true if you are using a browse or not.

If you change the size of the bitmaps you are going to have to compensate for this by changing where they are drawn on the screen.

If you were using a browse then the browse would figure out the new locations as long as the row height and column width was adjusted to the new dimensions. However, I seem to remember that there was a reason that you couldn't use a browse for this.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: change the size of a bitmap

Postby ukoenig » Sun Aug 09, 2009 10:25 pm

James,

I think after resizing, a new calculation is needed for the BMP-positions like You can see
on the Screenshot-part.

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Sun Aug 09, 2009 10:31 pm, edited 1 time in total.
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: change the size of a bitmap

Postby James Bott » Sun Aug 09, 2009 10:31 pm

Uwe,

>I think after resizing, a new calculation is needed for the BMP-positions like You can see
on the Screenshot-part.

Yes, that is what I was trying to say. New row and col positions will be needed for each bitmap. This may be less complicated than it seems, since you can do it two loops.

for nRow
for nCol = 1 to ...
...
next nCol
next nRow

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: change the size of a bitmap

Postby Silvio » Mon Aug 10, 2009 7:10 pm

this is the function draw the bitmaps
oPanel is a dialog

STATIC FUNCTION AssegnaBitmaps_NEW ( aBmps, aData, oPanel, nItem)
Local nY, nX
lOCAL nRow:=20
Local nCol:=BMP_V
Local oGet[TOTY]
local nFila:=1,x:=1

nY := 1
nX := 1


@ 5, 5 say "Fila" OF oApp:oPanel PIXEL SIZE BMP_H,BMP_V






For nY := 1 to TOTY
oGet[ nY ] := tget():new(nRow, nCol-BMP_V, SetGet( nY ), oApp:oPanel, BMP_H, BMP_V, "99",,,,,,,.t. )
oGet[ nY ]:lReadOnly:=.t.
For nX := 1 To TOTX
@ nrow, ncol BITMAP aBmps[ nY, nX ] RESOURCE "VUOTO" OF oApp:oPanel ;
SIZE BMP_H, BMP_V PIXEL ADJUST NOBORDER
ncol:=ncol+BMP_V
Next nX
@ nRow, nCol say ny OF oApp:oPanel PIXEL SIZE BMP_V,BMP_V COLOR CLR_BLACK,nRGB( 240, 232, 188 ) BORDER

nRow += BMP_H
nCol := BMP_V
Next nY


nCol:=BMP_V
For t=1 to Totx
@ nRow, nCol say t OF oApp:oPanel PIXEL SIZE BMP_H,BMP_V COLOR nRGB( 3, 56, 147 ),nRGB( 255, 255, 220 ) BORDER
nCol:=nCol+BMP_V

Next t


return nil




How I can resolve it ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 105 guests

cron