QuakeGod
2022-01-16 326d3e312c74726814c39c9d112faab03c4a167c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "StdAfx.h"
#include "MyCameraBase.h"
 
MyCamera::MyCamera(void)
{
    m_nWaitTime=500;
    ResultStr.Format(_T("Camera Not Defined!"));
}
 
 
MyCamera::~MyCamera(void)
{
}
 
MySimCamera::MySimCamera(void)
{
}
 
MySimCamera::~MySimCamera(void)
{
 
}
MySimCamera::MySimCamera(CString sFilePathName)
{
    SetSim(sFilePathName,0,0);
}
int MySimCamera::GetNextFilePathName()
{
    if (nTotalImageFileCount<=0) return -1;
    if (nCurImageFileIndex>=nTotalImageFileCount)
    {
        nCurImageFileIndex=0;
    }
    CFileFind FileFinder;
    int k=FileFinder.FindFile(ImageFilePathName);
    for (int i=0;i<=nCurImageFileIndex&&k;i++)
    {
        int k=FileFinder.FindNextFileW();
        int j=FileFinder.IsDirectory();
        int l=FileFinder.IsDots();
        if (j&&l) {continue;}            //¼ÈÊÇĿ¼£¬ÓÖÊǵ㡣ÄÇô¾ÍÊÇ .»ò.. Ìø¹ý
        if (j) {continue;}
    }
    CurFilePathName=FileFinder.GetFilePath();
    nCurImageFileIndex++;
    return 1;
}
int MySimCamera::SetSim(CString sFilePathName, int pixeltype, int w, int h)
{
    ImageFilePathName=sFilePathName;
    CFileFind FileFinder;
    int i=FileFinder.FindFile(ImageFilePathName);
    nTotalImageFileCount=0;
    nCurImageFileIndex=0;
 
    while (i)
    {
        i=FileFinder.FindNextFileW();
        int j=FileFinder.IsDirectory();
        int k=FileFinder.IsDots();
        if (j&&k) {continue;}            //¼ÈÊÇĿ¼£¬ÓÖÊǵ㡣ÄÇô¾ÍÊÇ .»ò.. Ìø¹ý
        if (j) {continue;}
        nTotalImageFileCount++;
        if (nTotalImageFileCount==1) //¶ÁÈ¡µ½µÄµÚÒ»¸öÎļþ
        {
            CurFilePathName=FileFinder.GetFilePath();
            Gdiplus::Bitmap bitmap1(CurFilePathName);
            w=bitmap1.GetWidth();
            h=bitmap1.GetHeight();
            m_nWidth=w;
            m_nHeight=h;
            m_PixelFormat=pixeltype;
        }
    }
    if (nTotalImageFileCount>0) {return nTotalImageFileCount;}
    else {return 0;}
}
int MySimCamera::OpenCamera(int)
{
    m_IsCameraOpened=1;
    ResultStr.Format(_T("SimÏà»ú%s´ò¿ª³É¹¦"),ImageFilePathName);
    return CameraOk;
}
int MySimCamera::CloseCamera()
{
    m_IsCameraOpened=0;
    return CameraOk;
}
int MySimCamera::SetExposureTime(double ExposeTime1)
{
    return CameraOk;
}
int MySimCamera::StartGrab()
{
    if (GetNextFilePathName()!=1) return CameraError;        //ÏÈ»ñÈ¡ÎļþÁбíÖеÄÎļþÃû
    ResultStr.Format(_T("File %s "),CurFilePathName);
    Gdiplus::Bitmap bitmap1(CurFilePathName);        //¶ÁÈ¡Îļþ
    int w,h;
    Gdiplus::BitmapData bitmapData1;
    w=bitmap1.GetWidth();
    h=bitmap1.GetHeight();
    Gdiplus::Rect rect1(0,0,w,h);
    Gdiplus::PixelFormat pixelformat1=bitmap1.GetPixelFormat();
    //ת»»¸ñʽ.
    if (pixelformat1==PixelFormat8bppIndexed)
    {    //ÈÏΪÊÇRaw¸ñʽ
        bitmapData1.Width=w;
        bitmapData1.Height=h;
        bitmap1.LockBits(&rect1,Gdiplus::ImageLockModeRead,PixelFormat8bppIndexed,&bitmapData1);
        Image1.CopyFromBuf(bitmapData1.Scan0,w,h,bitmapData1.Stride,m_PixelFormat);
        bitmap1.UnlockBits(&bitmapData1);
 
        return GrabOK;
    }else if (pixelformat1==PixelFormat24bppRGB)
    {
        return -1;
    }else if (pixelformat1==PixelFormat32bppRGB)
    {
        return -1;
    }
    return CameraOk;
}
int MySimCamera::StopGrab()
{
    return CameraOk;
}
int MySimCamera::WaitForGrabFinish(int nTimeWait)
{
    return CameraOk;
}
int MySimCamera::FetchImageData()
{
    return CameraOk;
}