Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
GDI+: cropping images
Retrieving the priority class for the current process
Comparing file times
Displaying Windows shell folders in TreeView control with Visual FoxPro FLL
Retrieving the User Datagram Protocol (UDP) listener table
Transparent Menu Class (requires VFP9)
Changing file attributes
Get the power status of your laptop computer
How to set Creation Date/Time for a folder (WinNT)
Loading a string resource from an executable file
Pocket PC: base class
StrDup returns a pointer to the duplicate of a source VFP string
Adding supplementary data to AVI files
Confining Windows calculator inside the VFP main window
Dial the Net Automatically
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Drawing Windows predefined bitmaps using the LoadBitmap functions
Converting twips to pixels and vice versa
Initiating Inet connection using a modem
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Retrieving information specific to the current Time Zone
Retrieving names for the registered clipboard formats
Clipping mouse cursor area
GDI+: custom Slider control
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: 133  
    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-2018 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.91.16.95)
    10 sec.Example: 'Accessing Adobe Reader 7.0 main menu from VFP application'
    21 sec.Function: 'CreateFont'
    31 sec.Function: 'GetForegroundWindow'
    40 sec.Function: 'GetVolumeInformation'
    Function group: 'File System'
    49 sec.
    Function group: 'Security'
    58 sec.Example: 'Windows Shell Icons displayed and exported to ICO files (Vista)'
    1.17 min.Example: 'Finding out if the current user is the Guest account'
    1.35 min.Function: 'PageSetupDlg'
    1.6 min.Function: 'GdipCreateMatrix'
    1.88 min.
    Function group: 'GDI+ Text'
    Google
    Advertise here!