Size of bitmaps

Size of bitmaps

Postby Silvio » Wed Apr 27, 2011 2:00 pm

I need to control if the user insert a 16x16 bitmap .
How I can to control it ?
Best Regards, Saludos

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

Re: Size of bitmaps

Postby ukoenig » Wed Apr 27, 2011 2:51 pm

Silvio,

LOCAL cWidth := ""
LOCAL cHeight := ""
cOldImg := ???? ( Restore if NO File selected !!! )

...
...
@ 5, 465 BTNBMP oBtn FILENAME c_path + "\Bitmaps\Text.bmp" ;
SIZE 40, 38 OF oDlg PIXEL NOBORDER ; // Width , Height
TOP ;
PROMPT " &Select Img" ;
FONT oFont ;
ACTION ( cFilter := "ALL (*.*)| *.*|" + ;
"JPG (*.jpg)|*.jpg|" + ;
"BMP (*.bmp)|*.bmp|" + ;
"PNG (*.png)| *.png|" + ;
"DIB (*.dib)| *.dib|" + ;
"ICO (*.ico)| *.ico|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TIF (*.tif)| *.tif|" + ;
"PSD (*.psd)| *.psd|" + ;
"PCD (*.pcd)| *.pcd|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|", ;
cNewImg := cGetFile32( cFilter,"Select a Picture",,"\" + CurDir() ), ;
IMG_SIZE(cNewImg), ;
MsgAlert( "Height : " + cHeight + CRLF + "Width : " + cWidth, "Image-size" ), ;

IIF( empty( cNewImg ), ( MsgAlert( "No file selected !","ATTENTION" ), cIMAGE := cOldImg ), NIL ), ;
cIMAGE := cFileNoPath( cNewImg ) )

oBtn:cToolTip = { "Select a " + CRLF + "Image", "Image-Selection", 1, CLR_BLACK, 14089979 }
...
...
// ------------------

FUNCTION IMG_SIZE(cImgName)
LOCAL oImage

DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

RETURN NIL


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: Size of bitmaps

Postby Silvio » Wed Apr 27, 2011 3:10 pm

uwe,
itried it

but i not show me the size


Image
Best Regards, Saludos

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

Re: Size of bitmaps

Postby Silvio » Wed Apr 27, 2011 3:16 pm

ok now I correct on this

@ 38, 263 BUTTON oBtnSel PROMPT "..." OF oDlg PIXEL SIZE 10, 9 ;
ACTION ( cFile:=cGetFile( "*.*", "Select a file" ),;
iif(Image_size(cFile), MsgAlert( "Dimensione non consentita" ),;
cTabImage:= relativePath( cFile )+cFileNoPath( cFile )) ,;
aGet[3]:refresh())


....

FUNCTION Image_size(cImgname)
LOCAL oImage
local lreturn :=.f.
DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

IF val(cHeight) >16 .and. val(cWidth) >16
MsgAlert( "Height : " + cHeight + CRLF + "Width : " + cWidth, "Image-size" )
lreturn :=.t.
else
lreturn :=.f.
endif
RETURN lreturn




and run ok GOOD MR UWE
Best Regards, Saludos

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

Re: Size of bitmaps

Postby ukoenig » Wed Apr 27, 2011 4:42 pm

Silvio,

something special ( maybe You like it ) :

Image

After Selection :

Image

Code: Select all  Expand view  RUN

FUNCTION MAIN()
LOCAL oDlg, oBtn, oGrp, aGet[3]
LOCAL cTabCodice := SPACE(10)
LOCAL cTabDesc := SPACE(10)
LOCAL cTabImage := SPACE(10)
LOCAL oBmp

c_path := CURDRIVE() + ":\" + GETCURDIR()  
cImgname := c_path + "
\Bitmaps\Help.bmp"
cWidth := "
16"
cHeight := "
16"

DEFINE DIALOG oDlg FROM 100, 100 TO 258,808;
TITLE "
MODIFY" PIXEL

@ 0, 4 GROUP oGrp TO 56, 350 OF oDlg PIXEL

@ 12, 10 SAY "
Codice:" OF oDlg SIZE 24, 8 PIXEL
@ 10, 39 GET aGet[1] var cTabCodice OF oDlg SIZE 25, 12 PIXEL READONLY

@ 26, 10 SAY "
Descri:" OF oDlg SIZE 22, 8 PIXEL
@ 24, 39 GET aGet[2] var cTabDesc OF oDlg SIZE 305, 12 PIXEL

@ 40, 10 SAY "
Image:" OF oDlg SIZE 21, 8 PIXEL
@ 38, 39 GET aGet[3] var cTabImage OF oDlg SIZE 205, 12 PIXEL

@ 36, 250 BTNBMP oBtnSel OF oDlg 2007  ;
FILE cImgName ;
SIZE 18, 18 ;
ACTION ( cFilter :=  "
ALL  (*.*)| *.*|" + ;
                 "
JPG  (*.jpg)|*.jpg|" + ;
                 "
BMP  (*.bmp)|*.bmp|" + ;
                                 "
RLE   (*.rle)| *.rle|", ;
                 cImgName := cGetFile32( cFilter,"
Select a Picture",,"\" + CurDir() ), ;
         IMG_SIZE(cImgName), ;
         IIF( empty( cImgName ), MsgAlert( "
No file selected !","ATTENTION" ), NIL ), ;
         cIMAGE := cFileNoPath( cImgName ), ;
                 cSUBDIR := cFileSubDir( cImgName ), ;
         cTabImage := cImage, aGet[3]:Refresh(), ;
         oBtnSel:SetFile( cImgName ) )
oBtnSel:lTransparent := .T.
oBtnSel:cToolTip = { "
Width : " + cWidth + CRLF + "Height : " +  cHeight, "Bmp-size", 1, CLR_BLACK, 14089979 }  

@ 60, 160 BUTTON oBtn PROMPT "
&Conferma" OF oDlg SIZE 42, 14 PIXEL DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 60, 211 BUTTON oBtn PROMPT "
An&nulla" OF oDlg SIZE 42, 14 PIXEL CANCEL ACTION ( oDlg:end( IDCANCEL ) )

ACTIVATE DIALOG oDlg

RETURN( NIL )

// ------------------

FUNCTION IMG_SIZE(cImgName)
LOCAL oImage

DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

RETURN NIL


Best Regards
Uwe :?:
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: Size of bitmaps

Postby acwoo1 » Fri May 13, 2011 12:09 pm

I tried the codes below:

FUNCTION MAIN()
LOCAL oDlg, oBtn, oGrp, aGet[3]
LOCAL cTabCodice := SPACE(10)
LOCAL cTabDesc := SPACE(10)
LOCAL cTabImage := SPACE(10)
LOCAL oBmp

c_path := CURDRIVE() + ":\" + GETCURDIR()
cImgname := c_path + "\Bitmaps\Help.bmp"
cWidth := "16"
cHeight := "16"

DEFINE DIALOG oDlg FROM 100, 100 TO 258,808;
TITLE "MODIFY" PIXEL

@ 0, 4 GROUP oGrp TO 56, 350 OF oDlg PIXEL

@ 12, 10 SAY "Codice:" OF oDlg SIZE 24, 8 PIXEL
@ 10, 39 GET aGet[1] var cTabCodice OF oDlg SIZE 25, 12 PIXEL READONLY

@ 26, 10 SAY "Descri:" OF oDlg SIZE 22, 8 PIXEL
@ 24, 39 GET aGet[2] var cTabDesc OF oDlg SIZE 305, 12 PIXEL

@ 40, 10 SAY "Image:" OF oDlg SIZE 21, 8 PIXEL
@ 38, 39 GET aGet[3] var cTabImage OF oDlg SIZE 205, 12 PIXEL

@ 36, 250 BTNBMP oBtnSel OF oDlg 2007 ;
FILE cImgName ;
SIZE 18, 18 ;
ACTION ( cFilter := "ALL (*.*)| *.*|" + ;
"JPG (*.jpg)|*.jpg|" + ;
"BMP (*.bmp)|*.bmp|" + ;
"RLE (*.rle)| *.rle|", ;
cImgName := cGetFile32( cFilter,"Select a Picture",,"\" + CurDir() ), ;
IMG_SIZE(cImgName), ;
IIF( empty( cImgName ), MsgAlert( "No file selected !","ATTENTION" ), NIL ), ;
cIMAGE := cFileNoPath( cImgName ), ;
cSUBDIR := cFileSubDir( cImgName ), ;
cTabImage := cImage, aGet[3]:Refresh(), ;
oBtnSel:SetFile( cImgName ) )
oBtnSel:lTransparent := .T.
oBtnSel:cToolTip = { "Width : " + cWidth + CRLF + "Height : " + cHeight, "Bmp-size", 1, CLR_BLACK, 14089979 }

@ 60, 160 BUTTON oBtn PROMPT "&Conferma" OF oDlg SIZE 42, 14 PIXEL DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 60, 211 BUTTON oBtn PROMPT "An&nulla" OF oDlg SIZE 42, 14 PIXEL CANCEL ACTION ( oDlg:end( IDCANCEL ) )

ACTIVATE DIALOG oDlg

RETURN( NIL )

// ------------------

FUNCTION IMG_SIZE(cImgName)
LOCAL oImage

DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

RETURN NIL
*************************

I can only see the display for bmp files. How to display jpg files using the above codes ?

Regards
Eddy
acwoo1
 
Posts: 173
Joined: Tue Nov 10, 2009 10:56 am

Re: Size of bitmaps

Postby Silvio » Fri May 13, 2011 2:16 pm

I can select any image format on my application here
and I see the size the image also jpg
perhaps you made a small mistake... see the function Image_size(cImgname)
mine is not as you wrote in your message
Best Regards, Saludos

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

Re: Size of bitmaps

Postby ukoenig » Fri May 13, 2011 2:33 pm

Maybe missing ?
FREEIMAGE.DLL is needed to display other Formats.

#include "FiveWin.ch"
#include "Image.ch"

Best Regards
Uwe :?:
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: Size of bitmaps

Postby Silvio » Fri May 13, 2011 2:47 pm

no uwe
if the oimage is closed and before he not saved the values of sizes of image then he cannot show these value
the error is on image_size() function or on the get there is an error

I made and here run ok:

@ 40, 10 SAY "Image:" OF oDlg SIZE 21, 8 PIXEL
@ 38, 39 GET aGet[3] var cTabImage OF oDlg SIZE 145, 12 PIXEL



@ 38, 186 BUTTON oBtnSel PROMPT "=>" OF oDlg PIXEL SIZE 10, 12 ;
ACTION ( cFile:=cGetFile( "*.*", "Select a file" ),;
iif(Image_size(cFile), MsgAlert( "Immagine non consentita.@@@ Sono consentite solo le immagini@@@ con risoluzione 16X16 con formato BITMAP" ),;
cTabImage:= relativePath( cFile )+cFileNoPath( cFile )) ,;
aGet[3]:refresh())




FUNCTION Image_size(cImgname)
LOCAL oImage
local lreturn :=.f.
DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

IF val(cHeight) >16 .and. val(cWidth) >16
MsgAlert( "Le misure dell'immagine selezionata sono:@@@ Altezza => " + cHeight +;
CRLF + "Larghezza => " + cWidth, "Dimensioni immagine selezionata" )
lreturn :=.t.
else
lreturn :=.f.
endif
RETURN lreturn
Best Regards, Saludos

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

Re: Size of bitmaps

Postby Silvio » Fri May 13, 2011 2:53 pm

OR GOOD THIS:



@ 38, 186 BUTTON oBtnSel PROMPT "=>" OF oDlg PIXEL SIZE 10, 12 ;
ACTION ( cFile:=cGetFile( "*.*", "Select a file" ),;
iif(Image_size(cFile,16,16), MsgAlert( "Immagine non consentita.@@@ Sono consentite solo le immagini@@@ con risoluzione 16X16 con formato BITMAP" ),;
cTabImage:= relativePath( cFile )+cFileNoPath( cFile )) ,;
aGet[3]:refresh())



//USAGE Image_size(NAME OF IMAGE,HEIGHT OF IMAGE , WITH OF IMAGE)

FUNCTION Image_size(cImgname,XF,yf)
LOCAL oImage
local lreturn :=.f.
DEFAULT XF:= 16,;
Yf:=16
DEFINE IMAGE oImage FILENAME cImgname
cWidth := ALLTRIM(STR(oImage:nWidth()))
cHeight := ALLTRIM(STR(oImage:nHeight()))
oImage:End()

IF val(cHeight) >XF .and. val(cWidth) >YF
MsgAlert( "Le misure dell'immagine selezionata sono:@@@ Altezza => " + cHeight +;
CRLF + "Larghezza => " + cWidth, "Dimensioni immagine selezionata" )
lreturn :=.t.
else
lreturn :=.f.
endif
RETURN lreturn
Best Regards, Saludos

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

Re: Size of bitmaps

Postby acwoo1 » Fri May 13, 2011 3:26 pm

Thanks for the help

I put in:

#include "FiveWin.ch"
#include "Image.ch"

and select a 7 x 15 jpg.
But it still does not show.

Please help

Regards
acwoo
acwoo1
 
Posts: 173
Joined: Tue Nov 10, 2009 10:56 am

Re: Size of bitmaps

Postby Silvio » Fri May 13, 2011 3:40 pm

use mine script please!!!!!!!!!!!!!!!!!!
Best Regards, Saludos

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

Re: Size of bitmaps

Postby acwoo1 » Sat May 14, 2011 1:44 am

Thanks Silvio

I tried your code.

But it does not show the picture in the button, something perhaps like:

oBtnSel:SetFile( cImgName )

Regards
acwoo
acwoo1
 
Posts: 173
Joined: Tue Nov 10, 2009 10:56 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests