Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to upload a local file to FTP server using FtpPutFile
Obtaining names and positions for shortcuts located on the Windows Desktop
Using FillMemory
Using GetBinaryType (WinNT only) to determine the type of an executable file
How to build UDP responder
Monitoring changes in a directory
Obtaining information about all user accounts on a server (WinNT only)
Retrieveing information about the active window (even if it is not owned by the calling process)
Using GetFileSize
A procedure for setting file times
CryptoAPI: Collection of Providers class
Dial the Net Automatically
How to display a dialog box with which the user can add a data source (DSN)
Locking mouse and keyboard input for the VFP application
Pocket PC: Folder Viewer
Reading and setting system access privileges for the current process
Testing MS Internet Explorer version installed
How to display Windows On-Screen Keyboard
Configuring DEVMODE structure for a printer
Enumerating network interfaces on the local computer
Pocket PC: custom RAPI class for operating with the Object Store Databases
Retrieving list of available disk drives
Using the heap of the calling process to allocate memory blocks
A client for testing non-blocking Winsock server
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: 76  
    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.72.91.94)
    4.64 hrs.Example: 'Creating a file, then moving it to another destination'
    6.46 hrs.Function: 'CryptEnumProviderTypes'
    Function group: 'Cryptography Reference'
     Example: 'Subclassing CommandButton control to create BackColor property'
    7.97 hrs.Function: 'PathToRegion'
    12.07 hrs.Example: 'Adding and deleting Scheduled Tasks using NetScheduleJob API functions'
     Example: 'Displaying dimmed window behind VFP top-level form'
    14.37 hrs.Links
    Page 5
     Function: 'CreateJobObject'
    Function group: 'Process and Thread'
     Function: 'CeCreateFile'
    Function group: 'Remote Application Programming (RAPI)'
    15.92 hrs.Example: 'How to print a bitmap file'
    Google
    Advertise here!