Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to find which fonts Windows uses for drawing captions, menus and message boxes
Retrieving current settings for an ODBC connection
Retrieving list of files on the FTP directory
How to create transparent areas inside a form -- punching holes in the form
Using custom Simple MapiSendMail class
Using the MessageBox Win32 function
Enumerating global and local group accounts on a server (WinNT/XP/2K)
How to generate GUID values
How to print picture stored in enhanced-format metafile (*.emf)
Locking mouse and keyboard input for the VFP application
Storing screen shot of a form to enhanced metafile (*.emf)
Displaying standard progress dialog box when copying files
How to make the caption of a VFP application flashing in the Windows task bar
Listing child windows for the Windows desktop
Monitoring changes in a directory
Reading security permissions for NTFS files and folders
Scanning a hierarchy of child windows down from the Windows Desktop
Creating a unique filename based on existing filename
Dial the Net Automatically
Finding out if the current user is the Guest account
How to run FoxPro application under different user name (impersonating user)
Printing text with the Escape function
Shortcut Menu Class
Storing registration key in the resources of an executable file
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: 84  
    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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (23.20.196.179)
    23.79 hrs.Example: 'How to print picture stored in enhanced-format metafile (*.emf)'
     Function: 'GetThreadLocale'
    1 day(s)Example: 'StrDup returns a pointer to the duplicate of a source VFP string'
     Example: 'Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)'
     Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
     Function: 'EndUpdateResource'
     Function: 'GetSystemMenu'
     Example: 'How to convert a bitmap file to monochrome format (1 bpp)'
    Language: 'Visual FoxPro'
     Example: 'Starting an external application in VFP using WinExec'
     Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
    Google
    Advertise here!