1. 將Bitmap屬性改成True
2. 加入圖片至資源檔, 按下[匯入], 選擇一張Bitmap照片48x48解析度(解析度依照需求而定)

me1237guy 發表在 痞客邦 留言(0) 人氣()

1.設計一個與硬體設備通訊之界面軟體。
2.設計網頁式工業用人機界面之應用程式, 以提供電腦, PDA, 或手機與週邊小型電子設備之間的通訊之界面軟體。
3.其通訊方式包括有線 USB 與無線 Bluetooth 等等。
4.應用程式更將擴張成為 Internet 網路即時雙向通訊之使用。

me1237guy 發表在 痞客邦 留言(0) 人氣()


在Conditional defines欄位加入
_FM_NO_REMAP;SKIP_INCLUDES
Include路徑加入

me1237guy 發表在 痞客邦 留言(2) 人氣()


使用Windows API: CreateFile, WriteFile, ReadFile, CloseHandle

me1237guy 發表在 痞客邦 留言(0) 人氣()


安裝下載
Basler pylon SDK x86 3.2.3.3215.exe
Basler pylon SDK x64 3.2.3.3215.exe
在Win7 x64 作業系統只能安裝x64版本, 無法安裝x86版本
開啟pylon IP Configuration Tool查詢關於Basler攝影機硬體相關資訊
控制台 -> 變更介面卡設定
滑鼠點選區域連線設定, 按右鍵<內容>
選擇<網際網路通訊協定第四版 TCP/IPv4>, 按下<內容>按鈕
設定與攝影機相同網段192.168.11.xxx, 其中xxx為1~253, 但不可以和攝影機設定成相同的網址192.168.11.13
開啟Pylon Viewer, 可以看到剛才偵測到的攝影機裝置 Basler raL2048-48gm
開啟檔案總管, 安裝路徑為 C:Program FilesBasler
進入Samples目錄夾, 選擇C語言次目錄, 開啟PylonCSamples
對應的User guide for C Programming為PylonCSDK
開啟PylonCSDK使用手冊
選擇[Link]->Input下拉選單, Object/Library輸入PylonC_MD_vc100.lib

Include路徑加入 $(PYLONC_ROOT)include
其中PYLONC_ROOT為系統環境變數
C:\\Program Files\\Basler\\pylon 3.2\\pylonc\\include
----------------------------------------------------------------------------------------------------
研究 SimpleGrab.c
/*
This sample illustrates how to use the PylonDeviceGrabSingleFrame() convenience
method for grabbing images in a loop. PylonDeviceGrabSingleFrame() grabs one
single frame in single frame mode.
Grabbing in single frame acquisition mode is the easiest way to grab images. Note: in single frame
mode the maximum frame rate of the camera can't be achieved. The full frame
rate can be achieved by setting the camera to the continuous frame acquisition
mode and by grabbing in overlapped mode, i.e., image acquisition is done in parallel
with image processing. This is illustrated in the OverlappedGrab sample program.
*/
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <pylonc/PylonC.h>
---------------------------------------------------------------------------------------------------
    /* Before using any pylon methods, the pylon runtime must be initialized. */
    PylonInitialize();                    // 初始化
    /* Enumerate all camera devices. You must call
    PylonEnumerateDevices() before creating a device! */
    res = PylonEnumerateDevices( &numDevices );
    CHECK(res);
    if ( 0 == numDevices )
    {
        fprintf( stderr, "No devices found!n" );
        /* Before exiting a program, PylonTerminate() should be called to release
           all pylon related resources. */
        PylonTerminate();   
        pressEnterToExit();
        exit(EXIT_FAILURE);
    }
    /* Get a handle for the first device found.  */
    res = PylonCreateDeviceByIndex( 0, &hDev );
    CHECK(res);
    /* Before using the device, it must be opened. Open it for configuring
    parameters and for grabbing images. */
    res = PylonDeviceOpen( hDev, PYLONC_ACCESS_MODE_CONTROL |   
                                                 PYLONC_ACCESS_MODE_STREAM );
    CHECK(res);
    /* Print out the name of the camera we are using. */
    {
        char buf[256];
        size_t siz = sizeof(buf);
        _Bool isReadable;
        isReadable = PylonDeviceFeatureIsReadable(hDev, "DeviceModelName");
        if ( isReadable )
        {
            res = PylonDeviceFeatureToString(hDev, "DeviceModelName", buf, &siz );
            CHECK(res);
            printf("Using camera %sn", buf);  // 印出裝置名稱
        }
    }
    /* Set the pixel format to Mono8, where gray values will be output as 8 bit values for each pixel. */
    /* ... Check first to see if the device supports the Mono8 format. */
    isAvail = PylonDeviceFeatureIsAvailable(hDev, "EnumEntry_PixelFormat_Mono8");
    if ( !isAvail )
    {
        /* Feature is not available. */
        fprintf(stderr, "Device doesn't support the Mono8 pixel format.");
        PylonTerminate();
        pressEnterToExit();
        exit (EXIT_FAILURE);
    }
   
    /* ... Set the pixel format to Mono8. */
    res = PylonDeviceFeatureFromString(hDev, "PixelFormat", "Mono8" );
    CHECK(res);
    /* Disable acquisition start trigger if available */
    isAvail = PylonDeviceFeatureIsAvailable( hDev, "EnumEntry_TriggerSelector_AcquisitionStart");
    if (isAvail)
    {
        res = PylonDeviceFeatureFromString( hDev, "TriggerSelector", "AcquisitionStart");
        CHECK(res);
        res = PylonDeviceFeatureFromString( hDev, "TriggerMode", "Off");
        CHECK(res);
    }
 
    /* Disable frame start trigger if available */
    isAvail = PylonDeviceFeatureIsAvailable( hDev, "EnumEntry_TriggerSelector_FrameStart");
    if (isAvail)
    {
        res = PylonDeviceFeatureFromString( hDev, "TriggerSelector", "FrameStart");
        CHECK(res);
        res = PylonDeviceFeatureFromString( hDev, "TriggerMode", "Off");
        CHECK(res);
    }
    /* For GigE cameras, we recommend increasing the packet size for better
       performance. If the network adapter supports jumbo frames, set the packet
       size to a value > 1500, e.g., to 8192. In this sample, we only set the packet size
       to 1500. */
    /* ... Check first to see if the GigE camera packet size parameter is supported
        and if it is writable. */
    isAvail = PylonDeviceFeatureIsWritable(hDev, "GevSCPSPacketSize");
    if ( isAvail )
    {
        /* ... The device supports the packet size feature. Set a value. */
        res = PylonDeviceSetIntegerFeature( hDev, "GevSCPSPacketSize", 1500 );
        CHECK(res);
    }
    /* Determine the required size of the grab buffer. */
    res = PylonDeviceGetIntegerFeatureInt32( hDev, "PayloadSize", &payloadSize );
    CHECK(res);
   
    /* Allocate memory for grabbing. */
    imgBuf = (unsigned char*) malloc( payloadSize );
    if ( NULL == imgBuf )
    {
        fprintf( stderr, "Out of memory.\n" );
        PylonTerminate();
        pressEnterToExit();
        exit(EXIT_FAILURE);
    }
    /* Grab some images in a loop. */
    for ( i = 0; i < numGrabs; ++i )
    {
        unsigned char min, max;
        PylonGrabResult_t grabResult;
        _Bool bufferReady;
        /* Grab one single frame from stream channel 0. The
        camera is set to single frame acquisition mode.
        Wait up to 500 ms for the image to be grabbed. */
        res = PylonDeviceGrabSingleFrame( hDev, 0, imgBuf, payloadSize,
            &grabResult, &bufferReady, 500 );
        if ( GENAPI_E_OK == res && !bufferReady )
        {
            /* Timeout occurred. */
            printf("Frame %d: timeout\n", i+1);
        }
        CHECK(res);
        /* Check to see if the image was grabbed successfully. */
        if ( grabResult.Status == Grabbed )
        {
            /* Success. Perform image processing. */
            getMinMax( imgBuf, grabResult.SizeX, grabResult.SizeY, &min, &max );
            printf("Grabbed frame #%2d. Min. gray value = %3u, Max. gray value = %3u\n", i+1, min, max);
            /* Display image */
            res = PylonImageWindowDisplayImageGrabResult(0, &grabResult);
            CHECK(res);
        }
        else if ( grabResult.Status == Failed )
        {
            fprintf( stderr,  "Frame %d wasn't grabbed successfully.  Error code = 0x%08X\n",
                i+1, grabResult.ErrorCode );
        }
    }
    /* Clean up. Close and release the pylon device. */
    res = PylonDeviceClose( hDev );
    CHECK(res);
    res = PylonDestroyDevice ( hDev );
    CHECK(res);
    /* Free memory for grabbing. */
    free( imgBuf );
    pressEnterToExit();
    /* Shut down the pylon runtime system. Don't call any pylon method after
       calling PylonTerminate(). */
    PylonTerminate();
    return EXIT_SUCCESS;

me1237guy 發表在 痞客邦 留言(4) 人氣()


專案類型 -> MFC -> MFC ActiveX控制項
專案名稱: ActiveXTest
類別檢視->CActiveXTestCtrl->新增兩個成員變數 _a 和 _b

me1237guy 發表在 痞客邦 留言(1) 人氣()


假設針對一個StringGrid名稱為SaveStringGrid
假設GridColor 為用於儲存對應SaveStringGrid陣列的每一個顏色值(Pixel Value)
首先, 在Unit1.h先宣告一個 TColor **GridColor;    
Form1的OnCreate事件加入下列程式碼:
     //建立與StringGrid相同大小的顏色陣列
     GridColor = new TColor* [SaveStringGrid->ColCount];
     for (int i=0; i<SaveStringGrid->ColCount; i++)
     GridColor[i] = new TColor[SaveStringGrid->RowCount];
     //設定顏色的初始值
     for (int i=0; i<SaveStringGrid->ColCount; i++)
     for (int k=0; k<SaveStringGrid->RowCount; k++)
     if (k==0) GridColor[i][k] = 0x00FFFF00;
     else        GridColor[i][k] = clWhite;
     SaveStringGrid->DefaultDrawing= false;
SaveStringGrid的OnDrawCell加入下列程式碼:
    SaveStringGrid->Canvas->Brush->Color = GridColor[ACol][ARow];
    SaveStringGrid->Canvas->FillRect(Rect);   
結果如下
此範例僅設定第一列成淺藍色, 可以延伸至設定每一個cell成不同顏色

me1237guy 發表在 痞客邦 留言(0) 人氣()


專案名稱:MyMathDLL
選擇DLL, 按下完成
MyMathDLL.cpp為專案的入口點, 內容為VC專案自動產生, 可以不用理他~

me1237guy 發表在 痞客邦 留言(0) 人氣()


參考資料:   Walkthrough: Creating and Using a Dynamic Link Library (C++)
dll的使用時機及意義:
強調重複使用程式碼, 而不必每次重新造輪子,只需要撰寫一次, 之後把這些函式庫引入並參考它們。

me1237guy 發表在 痞客邦 留言(0) 人氣()

#ifdef LOOK_FOR_ADDITIONAL_WIIMOTES
    // try to connect any additional wiimotes (just to show the code)
    _tprintf(_T("\n\n"));                                                              // [1]
    wiimote  *extra_motes [7] = { NULL }; // 7 should cover it  [2]
    unsigned detected          = 0;
    while(detected < 7)
        {
        wiimote *next = new wiimote;                                      // [3]
        if(!next->Connect(wiimote::FIRST_AVAILABLE))            // [4]
            break;
        extra_motes[detected++] = next;                                // [5]
        
        WHITE        ; _tprintf(_T("   also found wiimote "));       // [6]
        BRIGHT_GREEN; _tprintf(_T("%u"), detected+1);         // [7]
        if(next->IsBalanceBoard()) {                                       // [8]
            WHITE; _tprintf(_T("  (Balance Board)"));
            }
        _tprintf(_T("\n\n"));
# ifdef USE_BEEPS_AND_DELAYS
        Beep(1000 + (detected*100), 100);                             // [9]
        Sleep(500);
# endif
        }
    WHITE; _tprintf( ((detected == 7)? _T("     (can't detect any more).") :
                                       _T("    (no more found).")) );
# ifdef USE_BEEPS_AND_DELAYS
    Sleep(2000);
# endif
    // clean up
    for(unsigned index=0; index<detected; index++)
        delete extra_motes[index];
    
    SetConsoleCursorPosition(console, cursor_pos);
#endif // LOOK_FOR_ADDITIONAL_WIIMOTES

me1237guy 發表在 痞客邦 留言(0) 人氣()


1. 安裝WinDDK  Windows Driver Kit Version 7.1.0   
2. 安裝Balance Board C API   Wiiyourself1.15    

me1237guy 發表在 痞客邦 留言(0) 人氣()

#include <afxwin.h>
class MyApp : public CWinApp
{
    public:
        BOOL InitInstance()
        {
              CFrameWnd *Frame = new CFrameWnd(); 
              m_pMainWnd = Frame;                              //繼承CWinThread 類別的m_pMainWnd屬性
            
              Frame->Create(NULL, "Hello Win32");
              Frame->ShowWindow(SW_SHOW);
              return true;
        }
};
MyApp aApp;

me1237guy 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。