1 Son düzenleyen, soykanozcelik (10.06.2009 16:18:07)

Konu: GdiPlusX ile resim boyutlandırma

Daha once sorulmusmuydu yada MSN de mi bana sorulmustu hatirlamiyorum ama ihtiyaci olan arkadaslarin cok isine yarayacagini dusundugum asagidaki kodu yayinlayayim dedim. (Foxite.com bir arkadas yayinlamis). Kod daha onceden boyutlari belirtilmis sececeginiz bir image dosyasini belirttiginiz klasor ve boyutta yeniden kaydediyor. Uygulamalarda urun,personel,cari vs foto secimi ve kaydi islemlerinde cok kullanisli bir yontem.
biraz gelistirmek ve ihtiyaciniza gore resized fotonun ismi verilmesi vs size kalmis.Faydali olmasi dilegiyle...


system.app asagidaki linkten indirebilirsiniz.


Visual Fox Pro
Do Locfile("System.App")

 
With _Screen.System.Drawing
    #Define cr Chr(13)
    * dimensions desired for the new picture
    Local lnWidth, lnHeight,size0,size1
    Store 300 To lnWidth && istediginiz genislik
    Store 240 To  lnHeight && istediginiz yukseklik
 
    * Load the original Image
    Local loSrcImage As xfcBitmap
    afile=Getpict()  &&any picture
    loSrcImage = .Bitmap.New(afile)
 
    Set Compatible On
    size0=Fsize(afile)   &&original size in octets
 
    * Get the thumbnail with the desired size
    Local loThumbnail As xfcImage
    loThumbnail = loSrcImage.GetThumbnailImage(lnWidth, lnHeight)
    lcDest="c:\Resized.jpg" && kayit yeri
    * Save the resized image as Png
    loThumbnail.Save(lcDest, .Imaging.ImageFormat.JPEG)
    size1=Fsize(lcDest)
 
    Messagebox("Image source size (octets)="+Trans(size0)+cr+"Image resized size (octets)="+Trans(size1))
    Run/N "mspaint" &lcDest     &&show
 
Endwith
Return


http://vfpx.codeplex.com/Release/Projec … adId=69412

2 Son düzenleyen, soykanozcelik (10.06.2009 16:15:38)

Re: GdiPlusX ile resim boyutlandırma

biraz daha kolaylastirmak icin Function Haline getirdim

Visual Fox Pro
Image_Resizer(300,240,'D:\test.jpg')

 
Function  Image_Resizer
    Lparameters tnWidth,tnHeight,tcImgPath
 
    Do Locfile("System.App")
    With _Screen.System.Drawing
        #Define cr Chr(13)
        && dimensions desired for the new picture
        Local lnWidth, lnHeight,size0,size1
        Store m.tnWidth To lnWidth
        Store m.tnHeight To  lnHeight
 
        && Load the original Image
        Local loSrcImage As xfcBitmap
        afile=Getpict()  &&any picture
        loSrcImage = .Bitmap.New(afile)
 
        Set Compatible On
        size0=Fsize(afile)   &&original size in octets
 
        && Get the thumbnail with the desired size
        Local loThumbnail As xfcImage
        loThumbnail = loSrcImage.GetThumbnailImage(lnWidth, lnHeight)
        lcDest= m.tcImgPath &&"c:\Resized.jpg"
        && Save the resized image as Png
        loThumbnail.Save(lcDest, .Imaging.ImageFormat.JPEG)
        size1=Fsize(lcDest)
 
       &&Messagebox("Image source size (octets)="+Trans(size0)+cr+"Image resized size (octets)="+Trans(size1))
        &&Run/N "mspaint" &lcDest     &&show
 
    Endwith
    Return
Endfunc

3

Re: GdiPlusX ile resim boyutlandırma

Soykan abi, eline sağlık smile

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü