Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
Splash Screen for the VFP application
Displaying dimmed window behind VFP top-level form
Vertical Label control
Subclassing CommandButton control to create BackColor property
Storing content of the Clipboard to a bitmap file
Printing text with the Escape function
How to make a VFP form fading out when released (GDI version)
How to put a vertical text scrolling on the form (a movie cast)
How to put a horizontal text scrolling on the form (a news line, marquee)
Storing screen shot of a form to bitmap file
Bitmap Class for Visual FoxPro application
Playing WAV sounds simultaneously
Custom FTP Class for Visual FoxPro application
How to play AVI file on the _screen
Obtaining names and positions for shortcuts located on the Windows Desktop
Enumerating devices installed on the local machine
How to view icons stored in executable files (Icon Viewer) - II
Passing data records between VFP applications via the Clipboard
Enumerating Processes -- WinNT
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
CryptoAPI: Collection of Providers class
Monitoring clipboard content changes (VFP9)
Placing an arbitrary rectangular area of main VFP window on the Clipboard
GDI+: cropping images

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.


See also:
  • GDI+: creating scaled copy of image file
  • GDI+: rotating images

  • SET PROCEDURE TO gdiplus ADDITIVE
    
    * an instance of gdiplusinit should be created before 
    * and released after using any of gdi+ objects
    LOCAL gdip
    gdip = CREATEOBJECT("gdiplusinit")
    
    * source and target files
    LOCAL cSrcFile, cDstFile
    cSrcFile = "c:\windows\forest.bmp"
    cDstFile = SYS(2023) + "\test.jpg"
    
    *create Image object from the source file
    LOCAL src As gdiimage
    src = CREATEOBJECT("gdiimage", cSrcFile)
    IF src.himage = 0
        ? "Could not load source image file."
        RETURN
    ENDIF
    
    * set crop coordinates and dimensions
    LOCAL cropLeft, cropTop, cropWidth, cropHeight
    cropLeft = 10
    cropTop = 80
    cropWidth = src.imgwidth - m.cropLeft
    cropHeight = 60
    
    * create destination Bitmap object using crop dimensions
    LOCAL dst As gdibitmap
    dst = CREATEOBJECT("gdibitmap", m.cropWidth, m.cropHeight)
    
    * draw source image on the target bitmap;
    * note how coordinates and dimensions are set 
    dst.graphics.DrawImage(src, -m.cropLeft, -m.cropTop,;
        src.imgwidth, src.imgheight)
    
    IF NOT dst.SaveToFile(cDstFile)
        ? "Could not save file", cDstFile
    ELSE
    * open the file using default application
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER hwnd, STRING lpOperation,;
            STRING lpFile, STRING lpParameters,; 
            STRING lpDirectory, INTEGER nShowCmd
    
        = ShellExecute(0, "open", cDstFile, "", "", 3)
    ENDIF
    
    
    

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1352 bytes  
    Created: 2006-05-17 17:47:28  
    Modified: 2007-03-06 18:57:02  
    Visits in 7 days: 138  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    Initially I used the GdipDrawImageI to draw a part of the source image on target bitmap. A difference in resolutions (DPI) between them often caused dimension issues. So finally I decided to use the GdipDrawImageRectI for cropping.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.82.112.193)
    24 sec.Banners
    51 sec.Function: 'GdiplusShutdown'
    1.33 min.Function: 'GdipNewInstalledFontCollection'
    1.83 min.Function: 'GdipCreateBitmapFromGdiDib'
    2.35 min.Login
    3.73 min.Function: 'GdipDrawImageRectI'
    2 day(s)Function: 'FtpGetFile'
     Function: 'EndUpdateResource'
     Function: 'GetMonitorInfo'
     Function: 'DeregisterEventSource'
    Google
    Advertise here!