Page 1 of 1
Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Apr 27, 2011 2:00 pm
by Silvio
I need to control if the user insert a 16x16 bitmap .
How I can to control it ?
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Apr 27, 2011 2:51 pm
by ukoenig
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 NILBest Regards
Uwe
![Laughing :lol:](./images/smilies/icon_lol.gif)
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Apr 27, 2011 3:10 pm
by Silvio
uwe,
itried it
but i not show me the size
![Image](http://img43.imageshack.us/img43/6497/errsize.png)
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Apr 27, 2011 3:16 pm
by Silvio
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Wed Apr 27, 2011 4:42 pm
by ukoenig
Silvio,
something special ( maybe You like it ) :
After Selection :![Image](http://www.pflegeplus.com/pictures/img2.jpg)
- Code: Select all Expand view
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
![Question :?:](./images/smilies/icon_question.gif)
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 12:09 pm
by acwoo1
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 2:16 pm
by Silvio
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 2:33 pm
by ukoenig
Maybe missing ?
FREEIMAGE.DLL is needed to display other Formats.
#include "FiveWin.ch"
#include "Image.ch"Best Regards
Uwe
![Question :?:](./images/smilies/icon_question.gif)
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 2:47 pm
by Silvio
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 2:53 pm
by Silvio
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 3:26 pm
by acwoo1
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
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri May 13, 2011 3:40 pm
by Silvio
use mine script please!!!!!!!!!!!!!!!!!!
Re: Size of bitmaps
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat May 14, 2011 1:44 am
by acwoo1
Thanks Silvio
I tried your code.
But it does not show the picture in the button, something perhaps like:
oBtnSel:SetFile( cImgName )
Regards
acwoo