Initial
This commit is contained in:
185
bsptree/MAIN.CPP
Normal file
185
bsptree/MAIN.CPP
Normal file
@@ -0,0 +1,185 @@
|
||||
#include <common/pvector.hpp>
|
||||
#include <common/string.hpp>
|
||||
//#include <bsptree/treendex.hpp>
|
||||
//#include <bsptree/btree.hpp>
|
||||
|
||||
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
||||
{
|
||||
BTree<String> treeStrings;
|
||||
String firstString("SEAN");
|
||||
String secondString("RONI");
|
||||
|
||||
treeStrings.insertItem(firstString,TRUE);
|
||||
treeStrings.insertItem(secondString,TRUE);
|
||||
treeStrings.insertItem(secondString,TRUE);
|
||||
return treeStrings.leaves();
|
||||
}
|
||||
|
||||
#if 0
|
||||
#include <iostream.h>
|
||||
#include <fstream.h>
|
||||
#include <dos.h>
|
||||
#include <dir.h>
|
||||
#include <common/block.hpp>
|
||||
#include <common/block.tpp>
|
||||
#include <common/pvector.hpp>
|
||||
#include <common/pvector.tpp>
|
||||
#include <common/string.hpp>
|
||||
#include <common/bitmap.hpp>
|
||||
#include <bsptree/rgbtree.hpp>
|
||||
|
||||
void testPhaseThree(String srcBitmap,String dstBitmap);
|
||||
void testPhaseFour(void);
|
||||
|
||||
void main()
|
||||
{
|
||||
String bitmapOneName("C:\\WORK\\SCENE\\BMP\\COMPTILE.BMP");
|
||||
String bitmapTwoName("C:\\WORK\\SCENE\\BMP\\RIDEN.BMP");
|
||||
Bitmap bitmapOne(bitmapOneName);
|
||||
Bitmap bitmapTwo(bitmapTwoName);
|
||||
PurePalette paletteTwo((HPALETTE)bitmapTwo);
|
||||
PurePalette paletteOne((HPALETTE)bitmapOne);
|
||||
|
||||
if(!paletteOne.isIdentityPalette())cout << (LPSTR)bitmapOneName << " is not identity" << endl;
|
||||
else cout << (LPSTR)bitmapOneName << " is identity" << endl;
|
||||
paletteOne.identityPalette();
|
||||
if(!paletteOne.isIdentityPalette())cout << (LPSTR)bitmapOneName << " is not identity" << endl;
|
||||
else cout << (LPSTR)bitmapOneName << " is identity" << endl;
|
||||
if(!(paletteOne==paletteTwo))cout << "Palettes are not identical" << endl;
|
||||
else cout << "Palettes are identical" << endl;
|
||||
bitmapOne.setPalette(paletteOne);
|
||||
bitmapOne.saveBitmap("C:\\WORK\\SCENE\\BMP\\RIDEN2.BMP");
|
||||
#if 0
|
||||
PurePalette::PaletteIndex paletteIndex;
|
||||
String bitmapOneName("C:\\WORK\\SCENE\\BMP\\RIDEN.BMP");
|
||||
String bitmapTwoName("C:\\WORK\\SCENE\\BMP\\RIDEN2.BMP");
|
||||
String bitmapOrgName("C:\\WORK\\SCENE\\BMP\\RSKY1.BMP");
|
||||
Bitmap bitmapOne(bitmapOneName);
|
||||
Bitmap bitmapTwo(bitmapTwoName);
|
||||
Bitmap bitmapOrg(bitmapOrgName);
|
||||
PurePalette bitmapOnePalette((HPALETTE)bitmapOne);
|
||||
PurePalette bitmapTwoPalette((HPALETTE)bitmapTwo);
|
||||
PurePalette bitmapOrgPalette((HPALETTE)bitmapOrg);
|
||||
RGBColor rgbColorOne;
|
||||
RGBColor rgbColorTwo;
|
||||
RGBColor rgbColorOrg;
|
||||
BYTE bmOneByte;
|
||||
BYTE bmTwoByte;
|
||||
BYTE bmOrgByte;
|
||||
short bmDelta;
|
||||
short errors(0);
|
||||
char ch;
|
||||
|
||||
|
||||
if(bitmapOne.width()!=bitmapTwo.width()||bitmapOne.height()!=bitmapTwo.height())
|
||||
{cout << "Bitmaps have same dimensions" << endl;return;}
|
||||
for(short rowIndex=0;rowIndex<bitmapOne.height();rowIndex++)
|
||||
{
|
||||
for(short colIndex=0;colIndex<bitmapOne.width();colIndex++)
|
||||
{
|
||||
bmOneByte=bitmapOne.getBitmapByte(rowIndex,colIndex);
|
||||
bmTwoByte=bitmapTwo.getBitmapByte(rowIndex,colIndex);
|
||||
bmOrgByte=bitmapOrg.getBitmapByte(rowIndex,colIndex);
|
||||
if(bmOneByte!=bmTwoByte)
|
||||
{
|
||||
bitmapOnePalette.getPaletteColor(bmOneByte,rgbColorOne);
|
||||
bitmapTwoPalette.getPaletteColor(bmTwoByte,rgbColorTwo);
|
||||
bitmapOrgPalette.getPaletteColor(bmOrgByte,rgbColorOrg);
|
||||
bmDelta=(short)bmTwoByte-(short)bmOneByte;
|
||||
if(bmDelta<0)bmDelta=-bmDelta;
|
||||
cout << "Difference found at (" << rowIndex << "," << colIndex << ") DELTA=" << bmDelta << endl;
|
||||
cout << (LPSTR)bitmapOneName << " data is " << (short)bmOneByte << " color is " <<
|
||||
"(" << (short)rgbColorOne.red() << "," << (short)rgbColorOne.green() << "," << (short)rgbColorOne.blue() << ")" << endl;
|
||||
cout << (LPSTR)bitmapTwoName << " data is " << (short)bmTwoByte << " color is " <<
|
||||
"(" << (short)rgbColorTwo.red() << "," << (short)rgbColorTwo.green() << "," << (short)rgbColorTwo.blue() << ")" << endl;
|
||||
cout << (LPSTR)bitmapOrgName << " data is " << (short)bmOrgByte << " color is " <<
|
||||
"(" << (short)rgbColorOrg.red() << "," << (short)rgbColorOrg.green() << "," << (short)rgbColorOrg.blue() << ")" << endl;
|
||||
paletteIndex=bitmapTwoPalette.paletteIndex(rgbColorOne);
|
||||
cout << "(" << (short)rgbColorOne.red() << "," << (short)rgbColorOne.green() << "," << (short)rgbColorOne.blue() << ") index is " << (short)paletteIndex << " in " << (LPSTR)bitmapTwoName << endl;
|
||||
errors++;
|
||||
if(!(errors%5))cin >> ch;
|
||||
if('q'==ch)return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
||||
{
|
||||
testPhaseFour();
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void testPhaseFour()
|
||||
{
|
||||
ffblk ffblk;
|
||||
String firstFile;
|
||||
String secondFile;
|
||||
String pathFileSpec;
|
||||
String pathString("C:\\WORK\\ENGINE\\BMP");
|
||||
String separator("\\");
|
||||
String extensionString("*.BMP");
|
||||
|
||||
pathFileSpec=pathString;
|
||||
pathFileSpec+=separator;
|
||||
pathFileSpec+=extensionString;
|
||||
if(!::findfirst(pathFileSpec,&ffblk,FA_ARCH))
|
||||
{
|
||||
firstFile=pathString;
|
||||
firstFile+=separator;
|
||||
firstFile+=String(ffblk.ff_name);
|
||||
while(!::findnext(&ffblk))
|
||||
{
|
||||
secondFile=pathString;
|
||||
secondFile+=separator;
|
||||
secondFile+=String(ffblk.ff_name);
|
||||
testPhaseThree(firstFile,secondFile);
|
||||
firstFile=secondFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testPhaseThree(String srcBitmap,String dstBitmap)
|
||||
{
|
||||
PureVector<RGBColor> rgbColorOne;
|
||||
PureVector<RGBColor> rgbColorTwo;
|
||||
PureVector<RGBIndex> rgbIndexColorOne;
|
||||
PureVector<RGBIndex> rgbIndexColorTwo;
|
||||
RGBTree bspTree;
|
||||
RGBIndex searchRGB;
|
||||
WORD errorCount(0);
|
||||
|
||||
cout << "Looking at <" << (LPSTR)srcBitmap << ">" << endl << "<" << (LPSTR)dstBitmap << ">" << endl;
|
||||
Bitmap imageBitmapOne(srcBitmap);
|
||||
Bitmap imageBitmapTwo(dstBitmap);
|
||||
PurePalette purePaletteOne((HPALETTE)imageBitmapOne);
|
||||
PurePalette purePaletteTwo((HPALETTE)imageBitmapTwo);
|
||||
|
||||
purePaletteOne.getPaletteColors(rgbColorOne);
|
||||
purePaletteTwo.getPaletteColors(rgbColorTwo);
|
||||
rgbIndexColorOne.size(rgbColorOne.size());
|
||||
rgbIndexColorTwo.size(rgbColorTwo.size());
|
||||
for(short index=0;index<rgbColorOne.size();index++)rgbIndexColorOne[index]=rgbColorOne[index];
|
||||
for(index=0;index<rgbColorTwo.size();index++)rgbIndexColorTwo[index]=rgbColorTwo[index];
|
||||
if((!rgbIndexColorOne.size())||!(rgbIndexColorTwo.size())){cout << "Palette error." << endl;return;}
|
||||
bspTree.insertItems(rgbIndexColorTwo);
|
||||
size_t size((WORD)rgbIndexColorOne.size());
|
||||
cout << "Performing accuracy test..." << endl;
|
||||
for(int i=0;i<size;i++)
|
||||
{
|
||||
searchRGB=rgbIndexColorOne[i];
|
||||
if(!bspTree.searchItem(searchRGB,RGBTree::SearchExact))
|
||||
{
|
||||
cout << "Error : exact match failed " << i << endl;
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
cout << "Accuracy test complete." << endl;
|
||||
if(errorCount)cout << "Errors " << errorCount << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user