Hallo Brauche Hilfe! CreateDIBSection aufgerufenes Array als bmp speichern



  • Also ich soll das Array was das C-Programm als Bild anzeigt. Als bmp speichern...wie ist das möglich(Anfänger).

    Habe hier mal den Quellcode dabei gegeben..vielleicht hat jemand eine Idee...

    Wäre super...

    long FAR PASCAL bscanWndProc (HWND hwnd, unsigned msg, unsigned wParam, LONG lParam)
    {
    static BSCAN_INFO bi; //#### to support old handshake; will be deleted soon!!!
    static BSCAN_INFO *pbi; //pointer to BScanInfo structure
    static int i, backgnd;
    static PBITMAPINFO pbmi; //handle for the bitmap-info
    static HBITMAP hbm; //handle for the bitmap
    static HDC hdc, hdcBmp; //handle for the window- and compatible device contens
    // static short *buffer; //pointer to the rawDataBuffer
    static int time, timeOld;
    switch (msg)
    {
    case WM_CREATE:
    { unsigned long l = 0x01010101L;
    long pPalette;
    backgnd = 0;
    pbmi = (PBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER)+ sizeof(RGBQUAD)256); //alloc memory for bitmap
    pPalette = (long
    )(((BYTE
    )pbmi)+sizeof(BITMAPINFOHEADER)); //set pointer to palette-entry
    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); //size of bitmap header
    pbmi->bmiHeader.biWidth = 512; //width of bitmap
    pbmi->bmiHeader.biHeight = 512; //height of bitmap
    pbmi->bmiHeader.biPlanes = 1; //planes in graphic card (allways 1)
    pbmi->bmiHeader.biBitCount = 8; //number of bits for one color entry
    pbmi->bmiHeader.biCompression = BI_RGB; //no compression
    pbmi->bmiHeader.biSizeImage = 0;
    pbmi->bmiHeader.biXPelsPerMeter = 3650; //pixel dimensions
    pbmi->bmiHeader.biYPelsPerMeter = 3650;
    pbmi->bmiHeader.biClrUsed = 0; //all colors in palette are used
    pbmi->bmiHeader.biClrImportant = 0; //all colors in palette are important
    for(i=0;i<256;i++) (pPalette + i) = li; //palette: gray table
    hdc = GetDC(hwnd); //get device contens of the window
    hdcBmp = CreateCompatibleDC(hdc); //create a comatible device contens

    --------

    hbm = CreateDIBSection(hdcBmp, pbmi, DIB_RGB_COLORS, (void**)&(bscanDisplay.pixArray), NULL, 0); //create the bitmap

    for(i=0; i<B_PICTURE_CX * B_PICTURE_CY; i++)bscanDisplay.pixArray[i] = (BYTE)((BSCAN_DEFAULT_VALUE * 250)>>8); //default value
    ReleaseDC (hwnd, hdc); //hdc is no longer used
    pbi = & bi;
    }
    break;



  • Auch wenn du im falschen Subforum gepostest hast (WINAPI oder Ansi C wäre wohl besser gewesen -)

    Mittels fopen(), fwrite(), fclose() im Binärmodus ("b") die Daten nacheinander rausschreiben (zuerst den BMP-Header, dann die Bilddaten, s.a. http://de.wikipedia.org/wiki/Windows_Bitmap).



  • Dieser Thread wurde von Moderator/in pumuckl aus dem Forum C++ in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten