Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Winsock: sending email messages (SMTP, port 25)
Using EnumPrinters function to enumerate locally installed printers
Semi-transparent Form
Custom HttpRequest class (WinHTTP)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
How to convert a bitmap file to monochrome format (1 bpp)
Custom HttpRequest class (WinINet)
Compressing and decompressing files with Windows API Runtime Library routines
Custom FTP Class for Visual FoxPro application
Printing Image File, programmatically set print page orientation to landscape
How to create MD-5 and SHA-1 hash values from a string
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
GDI+: Creating thumbnails to preview images in a directory
Adding icon to the systray (requires VFP9)
Extended MessageBox Class
How to ping a remote site using ICMP API calls
GDI+: Storing content of the Clipboard to a bitmap file
Transparent Menu Class (requires VFP9)
How to activate Windows Calculator
Using Month Calendar Control (VFP9, Comctl32.dll)
How to print FoxPro form
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
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: 27  
    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-2010 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.0.85), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (38.107.191.107)
    6.75 min.Function: 'GetEnvironmentVariable'
    Function group: 'Process and Thread'
    2 day(s)Function: 'GdipCreateTexture'
     Example: 'Using custom Simple MapiSendMail class'
     
     Example: 'Enumerating Processes -- WinNT'
     Function: 'IsValidURL'
    Function group: 'URL Monikers'
     Function: 'GetMappedFileName'
     Function: 'waveOutGetNumDevs'
    Function group: 'Windows Multimedia'
     Function: 'SetBkColor'
    Function group: 'Painting and Drawing'
    6 day(s)Login
    Google
    Advertise here!