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
Using the MessageBox Win32 function
How to create transparent areas inside a form -- punching holes in the form
Storing screen shot of a form to enhanced metafile (*.emf)
Using custom Simple MapiSendMail class
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
Monitoring changes in a directory
Reading security permissions for NTFS files and folders
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
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 build UDP responder
How to run FoxPro application under different user name (impersonating user)
Obtaining names and positions for shortcuts located on the Windows Desktop
Printing text with the Escape function
GDI+: creating scaled copy of image file

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
Versions:
click to open
Before you begin:
The code creates source image object from an image file. It also creates empty destination bitmap object. Note that the Bitmap class is subclassed from the Image class. GDI+ flat API calls allow to use bitmap handles as if they were image handles.

Then the code uses the graphics of the destination bitmap both as a tool and canvas to draw the scaled source image on it. Finally the destination bitmap saves itself to file.

The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.

Make sure the source and destination file names are valid. The source file can be in any of graphics formats supported by the GDI+: BMP, GIF, JPG, TIF, EMF... The destination file type is limited to BMP, JPG, GIF, PNG and TIFF.

See also:
  • GDI+: cropping images
  • GDI+: rotating images

  •  
    SET PROCEDURE TO gdiplus ADDITIVE
     
    LOCAL cSrcFile, cDstFile, nScale, gdip As gdiplusinit,;
        src As gdiplus_image, dst as gdiplus_bitmap
     
    * an instance of gdiplusinit should be created before 
    * and released after using any of gdi+ objects
    gdip = CREATEOBJECT("gdiplusinit")
     
    cSrcFile = "c:\windows\forest.bmp"
    cDstFile = "d:\temp\test.png"
    nScale=4
     
    * creating Image object from the source file
    src = CREATEOBJECT("gdiimage", cSrcFile)
     
    IF src.himage = 0
        ? "Could not load source image file:",;
            src.errorcode
        RETURN
    ENDIF
     
    * creating destination Bitmap object,
    * setting its dimensions scaled from the source image file
    dst = CREATEOBJECT("gdibitmap",;
        src.imgwidth/nScale, src.imgheight/nScale)
     
    * drawing the source file using the graphics object 
    * of the destination Bitmap
    dst.graphics.DrawImage(src, 0,0,;
        src.imgwidth/nScale, src.imgheight/nScale)
     
    IF NOT dst.SaveToFile(cDstFile)
        ? "Error code:", dst.errorcode
    ELSE
    * using default application to open the file
        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:
    • ~
    1246 bytes  
    Created: 2004-07-27 10:28:48  
    Modified: 2007-03-06 18:57:59  
    Visits in 7 days: 100  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    .Net code: GetThumbnailImage works well when the requested thumbnail image has a size of about 120 x 120.
    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 (184.73.74.47)
    4.86 hrs.Example: 'Reading parameters of streams in AVI file'
     Function: 'LoadIcon'
     Example: 'Pocket PC: base class'
    5.09 hrs.Example: 'Pocket PC: custom RAPI class for operating with the System Registry'
     Example: 'Storing screen shot of a form to enhanced metafile (*.emf)'
     Function: 'SQLCreateDataSource'
    Function group: 'ODBC API'
    5.21 hrs.Function: 'CreateWindow'
     Function: 'UnlockServiceDatabase'
    Function group: 'Service'
    5.78 hrs.Example: 'The window and its ancestors'
     Example: 'Creating two-byte hashes for a list of URLs'
    Google
    Advertise here!