www.pudn.com > ColorProcess.rar
To Read all the content
[file head]:
//**********************************************************************
//
// AIBAPI.CPP
//
// Source file for Device-Independent Bitmap (DIB) API.
//
//**********************************************************************
#define STRICT // enable strict type checking
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <direct.h>
#include <stdlib.h>
#include <assert.h>
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include "dibapi.h"
////////////////////////////////////////////////////////////////////////////////////
// Local use only function prototypes
////////////////////////////////////////////////////////////////////////////////////
BOOL CopyColorTable(LPBITMAPINFO lpTarget, LPBITMAPINFO lpSource, HPALETTE hPalSrc);
void DecreaseContrast(BYTE *pByte, const int Level, const float Grad);
void IncreaseContrast(BYTE *pByte, const int Low, const int High,
... ...
[file tail]:
... ...
ib);
if (! bmi)
return FALSE;
WaitCursorBegin();
// get color number
WORD wNumColors = DIBNumColors((LPBYTE)bmi);
if (wNumColors) // There is palette
{
for (WORD i=0; i<wNumColors; i++)
{
Exposure(threshold,
&amt;(bmi->bmiColors[i].rgbRed),
&amt;(bmi->bmiColors[i].rgbGreen),
&amt;(bmi->bmiColors[i].rgbBlue));
}
}
else // No palette
{
// bits position
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)bmi;
LPBYTE lpBits = (LPBYTE)lpbi + lpbi->biSize;
int nDelta = WIDTHBYTES(lpbi->biBitCount*lpbi->biWidth) - lpbi->biWidth*lpbi->biBitCount/8;
BYTE r, g, b;
for (int ny=0; ny<lpbi->biHeight; ny++)
{
for (int nx=0; nx<lpbi->biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
Exposure(threshold,&amt;r, &amt;g, &amt;b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
}
GlobalUnlock(hDib);
WaitCursorEnd();
return TRUE;
}