Click here to Skip to main content
15,896,557 members
Articles / Programming Languages / C#

Universal Framework for Science and Engineering - Part 2: Regression

Rate me:
Please Sign up or sign in to vote.
4.77/5 (19 votes)
11 Jul 20067 min read 51.2K   5K   76  
An article on universal scalable engineering framework applications.
/*    PortTool v2.2     dibapi.h          */ 
 
/* 
 *  dibapi.h 
 * 
 *  ** Win32 Version ** 
 * 
 *  Copyright 1991-1998 Microsoft Corporation. All rights reserved 
 * 
 *  Header file for Device-Independent Bitmap (DIB) API.  Provides 
 *  function prototypes and constants for the following functions: 
 * 
 *  BitmapToDIB()        - Creates a DIB from a bitmap 
 *  ChangeBitmapFormat() - Changes a bitmap to a specified DIB format 
 *  ChangeDIBFormat()    - Changes a DIB's BPP and/or compression format 
 *  CopyScreenToBitmap() - Copies entire screen to a standard Bitmap 
 *  CopyScreenToDIB()    - Copies entire screen to a DIB 
 *  CopyWindowToBitmap() - Copies a window to a standard Bitmap 
 *  CopyWindowToDIB()    - Copies a window to a DIB 
 *  CreateDIBPalette()   - Creates a palette from a DIB 
 *  CreateDIB()          - Creates a new DIB 
 *  DestroyDIB()         - Deletes DIB when finished using it 
 *  DIBError()           - Displays message box with error message 
 *  DIBHeight()          - Gets the DIB height 
 *  DIBNumColors()       - Calculates number of colors in the DIB's color table 
 *  DIBToBitmap()        - Creates a bitmap from a DIB 
 *  DIBWidth()           - Gets the DIB width 
 *  FindDIBBits()        - Sets pointer to the DIB bits 
 *  GetSystemPalette()   - Gets the current palette 
 *  LoadDIB()            - Loads a DIB from a file 
 *  PaintBitmap()        - Displays standard bitmap in the specified DC 
 *  PaintDIB()           - Displays DIB in the specified DC 
 *  PalEntriesOnDevice() - Gets the number of palette entries 
 *  PaletteSize()        - Calculates the buffer size required by a palette 
 *  PrintDIB()           - Prints the specified DIB 
 *  PrintScreen()        - Prints the entire screen 
 *  PrintWindow()        - Prints all or part of a window 
 *  SaveDIB()            - Saves the specified dib in a file 
 * 
 * See the file DIBAPI.TXT for more information about these functions. 
 * 
 */ 

#include "windows.h"
 
/* Handle to a DIB */ 
#define HDIB HANDLE 
 
 
/* Print Area selection */ 
#define PW_WINDOW        1 
#define PW_CLIENT        2 
 
 
/* Print Options selection */ 
#define PW_BESTFIT       1 
#define PW_STRETCHTOPAGE 2 
#define PW_SCALE         3 
 
/* DIB Macros*/ 
 
// WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits" 
// parameter is the bit count for the scanline (biWidth * biBitCount), 
// and this macro returns the number of DWORD-aligned bytes needed  
// to hold those bits. 
 
#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4) 

typedef unsigned short WORD;

/* Error constants */ 
enum { 
      ERR_MIN = 0,                     // All error #s >= this value 
      ERR_NOT_DIB = 0,                 // Tried to load a file, NOT a DIB! 
      ERR_MEMORY,                      // Not enough memory! 
      ERR_READ,                        // Error reading file! 
      ERR_LOCK,                        // Error on a GlobalLock()! 
      ERR_OPEN,                        // Error opening a file! 
      ERR_CREATEPAL,                   // Error creating palette. 
      ERR_GETDC,                       // Couldn't get a DC. 
      ERR_CREATEDDB,                   // Error create a DDB. 
      ERR_STRETCHBLT,                  // StretchBlt() returned failure. 
      ERR_STRETCHDIBITS,               // StretchDIBits() returned failure. 
      ERR_SETDIBITSTODEVICE,           // SetDIBitsToDevice() failed. 
      ERR_STARTDOC,                    // Error calling StartDoc(). 
      ERR_NOGDIMODULE,                 // Couldn't find GDI module in memory. 
      ERR_SETABORTPROC,                // Error calling SetAbortProc(). 
      ERR_STARTPAGE,                   // Error calling StartPage(). 
      ERR_NEWFRAME,                    // Error calling NEWFRAME escape. 
      ERR_ENDPAGE,                     // Error calling EndPage(). 
      ERR_ENDDOC,                      // Error calling EndDoc(). 
      ERR_SETDIBITS,                   // Error calling SetDIBits(). 
      ERR_FILENOTFOUND,                // Error opening file in GetDib() 
      ERR_INVALIDHANDLE,               // Invalid Handle 
      ERR_DIBFUNCTION,                 // Error on call to DIB function 
      ERR_MAX                          // All error #s < this value 
     }; 
 
 
 
/* Function prototypes */ 
 
HDIB BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal); 
HDIB ChangeBitmapFormat (HBITMAP hBitmap, 
                                   WORD     wBitCount, 
                                   DWORD    dwCompression, 
                                   HPALETTE hPal); 
HDIB ChangeDIBFormat (HDIB hDIB, WORD wBitCount, 
                                DWORD dwCompression); 
HBITMAP CopyScreenToBitmap (LPRECT); 
HDIB CopyScreenToDIB (LPRECT); 
HBITMAP CopyWindowToBitmap (HWND, WORD); 
HDIB CopyWindowToDIB (HWND, WORD); 
HPALETTE CreateDIBPalette (HDIB); 
HDIB CreateDIB(DWORD, DWORD, WORD); 
void DestroyDIB (HDIB); 
void DIBError (int ErrNo); 
DWORD DIBHeight (LPSTR lpDIB); 
WORD DIBNumColors (LPSTR lpDIB); 
HBITMAP DIBToBitmap (HDIB hDIB, HPALETTE hPal); 
DWORD DIBWidth (LPSTR lpDIB); 
LPSTR FindDIBBits (LPSTR lpDIB); 
HPALETTE GetSystemPalette (void); 
HDIB LoadDIB (LPSTR); 
BOOL PaintBitmap (HDC, LPRECT, HBITMAP, LPRECT, HPALETTE); 
BOOL PaintDIB (HDC, LPRECT, HDIB, LPRECT, HPALETTE); 
int PalEntriesOnDevice (HDC hDC); 
WORD PaletteSize (LPSTR lpDIB); 
WORD PrintDIB (HDIB, WORD, WORD, WORD, LPSTR); 
WORD PrintScreen (LPRECT, WORD, WORD, WORD, LPSTR); 
WORD PrintWindow (HWND, WORD, WORD, WORD, WORD, LPSTR); 
void SaveDIB (HDIB, LPSTR);
HBITMAP CopyHDCToBitmap(HDC hDC, int width, int height);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions