Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid takes long time when Image control used
Message
From
18/07/2010 11:14:22
 
 
To
18/07/2010 10:45:24
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01472780
Message ID:
01472855
Views:
63
>>Cetin,
>>
>>Thanks for your reply. Some more questions though:
>>
>>1. So, the reason for the hourglass coming out is mainly due to the sheer big size (5Mb) of the image file? This won't happen then if the images were smaller?
>>
>>2. In your FAQ, a container was used. So, one can also do away with the container?
>>
>>3. Is there a utility (freeware preferably) that automates the 'shrinking' process of images in a folder?
>>
>>Thanks!
>
>1) Yes
>2) Yes. You don't have to use a container. Directly use an image control and set picture property. In that FAQ I was trying to show even with containers (multiple controls then might be in it) it is easy.
>3) Yes. You can use GDI+ API to do that programmatically. Check
>http://vfpx.codeplex.com/wikipage?title=GDIPlusX%20References
>
>A utility I don't know but I am sure there must be hundreds of them if you search.
>Cetin

Here's my imgresize() function using gdiplusx
lnSizeOfNewImage=imgresize('d:\data\myoldfile.jpg','d:\data\mynewfile',.T.,600,600)

Function imgresize
Lparameters pcFromFile, pcToFile, plHQ, pnWidth, pnHeight
Do Case 
   Case Type('pcFromFile')#'C'
   Case !Empty(Justext(pcFromFile))
   Case Adir(temp,pcFromFile)=0
   Otherwise 
      Return -1
Endcase 
Local lcType, lnWidth, lnHeight, loZ, lnRatio, lnMaxWidth, lnMaxHeight, loSrcImage, loResized,; 
   loGfx, loType, lnReturn, lcTempfile, lnReturn
lnReturn=0
If Type('pnHeight')='N'
   lnMaxHeight=pnHeight
Else    
   lnMaxHeight=600
Endif      
If Type('pnWidth')='N'
   lnMaxWidth=pnWidth
Else    
   lnMaxWidth=800
Endif      
If Type('pcToFile')#'C' 
   pcToFile = pcFromFile
Endif 
If Empty(Justext(pcToFile))
   pcTofile=Forceext(pcTofile,Justext(pcFromfile))
Endif    
If !type('_screen.system')='O'
   Do prog\gdiplusx\app\system.app && Change the path if necessary
Endif    
lcType=Upper(Justext(pcToFile))
If Lower(pcFromFile)==Lower(pcToFile)
   lcTempfile=Sys(2023)+'\'+Sys(3)+'.'+lcType
   Copy File (pcFromFile) To (lcTempfile)
   Erase (pcFromFile)
   pcFromFile = lcTempfile
Endif    
If plHQ
   With _screen.system.Drawing 
      loSrcImage = .Bitmap.New(pcFromFile)
      lnWidth=loSrcImage.width
      lnHeight=loSrcImage.height
      lnRatio = Min(lnMaxHeight/lnHeight, lnMaxWidth/lnWidth)
      lnWidth=lnWidth*lnRatio
      lnHeight = lnHeight*lnRatio
      loResized = .Bitmap.New(lnWidth, lnHeight,.Imaging.PixelFormat.Format32bppARGB)
      loResized.SetResolution(loSrcImage.HorizontalResolution, loSrcImage.VerticalResolution)
      loGfx = .Graphics.FromImage(loResized)
      loGfx.SmoothingMode = .Drawing2D.SmoothingMode.HighQuality
      loGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic
      loGfx.DrawImage(loSrcImage, 0, 0, lnWIdth, lnHeight)
      Do Case 
         Case lcType='TIF'
            loType='.Imaging.ImageFormat.Tiff'
         Case lcType='JPG'
            loType='.Imaging.ImageFormat.Jpeg'
         Case lcType='PNG'
            loType='.Imaging.ImageFormat.Png'
         Case lcType='GIF'
            loType='.Imaging.ImageFormat.Gif'
         Case lcType='BMP'
            loType='.Imaging.ImageFormat.Bmp'
      Endcase    
      loResized.Save(pcToFile, &loType) 
   Endwith 
Else 
   With _screen.system.Drawing 
      * Load the original Image
      loSrcImage = .Bitmap.New(pcFromFile)
      lnWidth=loSrcImage.width
      lnHeight=loSrcImage.height
      lnRatio = Min(lnMaxHeight/lnHeight, lnMaxWidth/lnWidth)
      lnWidth=lnWidth*lnRatio
      lnHeight = lnHeight*lnRatio
      loResized = loSrcImage.GetThumbnailImage(lnWidth, lnHeight)
      Do Case 
         Case lcType='TIF'
            loType='.Imaging.ImageFormat.Tiff'
         Case lcType='JPG'
            loType='.Imaging.ImageFormat.Jpeg'
         Case lcType='PNG'
            loType='.Imaging.ImageFormat.Png'
         Case lcType='GIF'
            loType='.Imaging.ImageFormat.Gif'
         Case lcType='BMP'
            loType='.Imaging.ImageFormat.Bmp'
      Endcase    
      loResized.Save(pcToFile, &loType) 
   Endwith 
Endif
loSrcImage =.null.
Release loSrcImage 
loResized=.null.
Release loResized
If !Empty(lcTempfile)
   Erase (lcTempfile)
Endif    
If lnReturn=0 And Adir(temp,pcToFile)>0
   lnReturn=temp(1,2)
Endif 
Return lnReturn
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform