Posted: 20th Jan 2004 10:27
This is the DLL code used to interface with Balrogsoft's DLL. You need IanM's DBPro interface to compile - I dont really intend to develop this any further.

+ Code Snippet
// ICAM.cpp : Defines the entry point for the DLL application.
// Written by Nicholas Kingsley

#include "stdafx.h"
#include "DBPro.hpp"
#include "globstruct.h"
#include "stdio.h"
#include "stdlib.h"

GlobStruct* g_pGlob = NULL;
HMODULE hModule=NULL;

template <typename type, typename val>
void __poke(DWORD Addr, val Value)
{ 
	*((type*)(Addr))=(type)(Value); 
}

template <typename type>
type __peek(DWORD Addr)
{ 
	return *((type *)(Addr)); 
}

typedef struct __SIZE {
	long x;
	long y;
	long totalSize;
	} __SIZE;

using namespace DBPro;

struct __SIZE	size;
long			address;	// Address to read from
DWORD			addr;		// Address to write to
DWORD			lineStep;	// Number of bytes to add for next line

long (PASCAL *iCamInitCapture)(long DriverNumber);
void (PASCAL *iCamClose)(void);
void (PASCAL *iCamGetCapSize)(long addr);
void (PASCAL *iCamVideoStreamCallback)(long lWnd,long lpVHdr);
void (PASCAL *iCamGetMotion)(void);
void (PASCAL *iCamCopyWebcamImage)(long addr);
void (PASCAL *iCamSetCallbackAddress)(long addr);
void (PASCAL *iCamSetAutomaticBright)(long addr);
void (PASCAL *iCamCPUMode)(long cpuMode);

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

EXPORT void Constructor ( void )
{
	// Create memory here
	if ((hModule=LoadLibrary("ICamPlay.DLL"))!=NULL)
	{
		(FARPROC &) iCamInitCapture=GetProcAddress(hModule,"iCamInitCapture");
		(FARPROC &) iCamClose=GetProcAddress(hModule,"iCamClose");
		(FARPROC &) iCamGetCapSize=GetProcAddress(hModule,"iCamGetCapSize");
		(FARPROC &) iCamVideoStreamCallback=GetProcAddress(hModule,"iCamVideoStreamCallback");
		(FARPROC &) iCamGetMotion=GetProcAddress(hModule,"iCamGetMotion");
		(FARPROC &) iCamCopyWebcamImage=GetProcAddress(hModule,"iCamCopyWebcamImage");
		(FARPROC &) iCamSetCallbackAddress=GetProcAddress(hModule,"iCamSetCallbackAddress");
		(FARPROC &) iCamSetAutomaticBright=GetProcAddress(hModule,"iCamSetAutomaticBright");
		(FARPROC &) iCamCPUMode=GetProcAddress(hModule,"iCamCPUMode");
	}
}

EXPORT void Destructor ( void )
{
	// Free memory here
	if (hModule)
	{
		(iCamSetCallbackAddress)(0);
		(iCamClose)();
		FreeLibrary(hModule);
		hModule=NULL;
	}
}

EXPORT void ReceiveCoreDataPtr ( LPVOID pCore )
{
	// Get Core Data Pointer here
	g_pGlob = (GlobStruct*)pCore;
}

void VideoStreamCallback(long lWnd,long VHDR)
{
	(iCamVideoStreamCallback)(lWnd,VHDR);
	(iCamGetMotion)();
	(iCamCopyWebcamImage)(address);
}

EXPORT DWORD initCamera(long cpuMode)
{
long result;

	if (hModule)
	{
		(iCamCPUMode)(cpuMode);
		result=(iCamInitCapture)(0);
		(iCamGetCapSize)((long) &size);	
		size.totalSize=size.x*size.y*4;	
		return (result);
	}
	else
	{
		return (0);
	}
}

EXPORT DWORD getXSize(void)
{
	return ((DWORD) size.x);
}

EXPORT DWORD getYSize(void)
{
	return ((DWORD) size.y);
}

EXPORT DWORD getTotalSize(void)
{
	return ((DWORD) size.totalSize);
}

EXPORT void setUpCallback(DWORD addr)
{
	if (hModule)
	{
		address=addr;
		(iCamSetCallbackAddress)((DWORD) &VideoStreamCallback);
	}
}

EXPORT void setAutoBright(DWORD bright,DWORD croma)
{
struct {
	long AutomaticBright;
	long BackChromaValue;
	} autoB;

	if (hModule)
	{
		autoB.AutomaticBright=bright & 0xFF;
		autoB.BackChromaValue=croma & 0xFF;
		(iCamSetAutomaticBright)((long) &autoB);
	}

}

// Internal
DWORD inline offset(DWORD x,DWORD y)
{
DWORD ptr;

	ptr=((address+size.totalSize)-(y*(size.x<<2)))+(x<<2);
	return (__peek<long>(ptr));
}

EXPORT void pasteToBitmap(DWORD bitmap,DWORD image)
{
register int x,y;

	if ((hModule) && BitmapExist(bitmap))
	{
		SetCurrentBitmap(bitmap);
		LockPixels();		
		addr=GetPixelsPointer();
		lineStep=GetPixelsPitch();
		for (y=0; y<size.y; y+=2)
		{
			for (x=0; x<size.x; x+=2)
			{	
				__poke<long>(addr+(x<<2),offset(x,y));
				__poke<long>(addr+((x+1)<<2),offset(x+1,y));

				__poke<long>(addr+(x<<2)+lineStep,offset(x,y+1));
				__poke<long>(addr+((x+1)<<2)+lineStep,offset(x+1,y+1));

			}

			addr+=lineStep<<1;
		}
		
		UnlockPixels();
		if (image)
		{		
			if (ImageExist(image))
			{
				DeleteImage(image);
			}

			GetImage(image,0,0,size.x,size.y,1);		
		}	

		SetCurrentBitmap(0);	
	}
}
Posted: 20th Jan 2004 18:10
is that dbpro code?
soz.. what does this do?
Posted: 20th Jan 2004 18:50
No, its C code - its for getting webcam data & displaying it.
Posted: 21st Jan 2004 2:18
it's the code for the .dll, if ya wanna compile it for yourself.
Posted: 21st Jan 2004 14:30
Thats right.