Ignore:
Timestamp:
Jul 29, 2006, 6:43:07 AM (19 years ago)
Author:
bird
Message:

Two classes (CPMScreen and CPMKeyState) + the hook dll left (and debugging of course).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/synergy/lib/platform/CPMClipboardBitmapConverter.cpp

    r2751 r2752  
    22 * synergy -- mouse and keyboard sharing utility
    33 * Copyright (C) 2004 Chris Schoeneman
     4 * Copyright (C) 2006 Knut St. Osmundsen
    45 *
    56 * This package is free software; you can redistribute it and/or
     
    1314 */
    1415
    15 #include "CMSWindowsClipboardBitmapConverter.h"
     16#include "CPMClipboardBitmapConverter.h"
    1617#include "CLog.h"
    1718
    1819//
    19 // CMSWindowsClipboardBitmapConverter
     20// CPMClipboardBitmapConverter
    2021//
    2122
    22 CMSWindowsClipboardBitmapConverter::CMSWindowsClipboardBitmapConverter()
     23CPMClipboardBitmapConverter::CPMClipboardBitmapConverter()
    2324{
    2425        // do nothing
    2526}
    2627
    27 CMSWindowsClipboardBitmapConverter::~CMSWindowsClipboardBitmapConverter()
     28CPMClipboardBitmapConverter::~CPMClipboardBitmapConverter()
    2829{
    2930        // do nothing
     
    3132
    3233IClipboard::EFormat
    33 CMSWindowsClipboardBitmapConverter::getFormat() const
     34CPMClipboardBitmapConverter::getFormat() const
    3435{
    3536        return IClipboard::kBitmap;
    3637}
    3738
    38 UINT
    39 CMSWindowsClipboardBitmapConverter::getWin32Format() const
     39ULONG
     40CPMClipboardBitmapConverter::getPMFormat() const
    4041{
    41         return CF_DIB;
     42        return CF_BITMAP;
    4243}
    4344
    44 HANDLE
    45 CMSWindowsClipboardBitmapConverter::fromIClipboard(const CString& data) const
     45ULONG
     46CPMClipboardBitmapConverter::getPMFormatInfo() const
    4647{
    47         // copy to memory handle
    48         HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, data.size());
    49         if (gData != NULL) {
    50                 // get a pointer to the allocated memory
    51                 char* dst = (char*)GlobalLock(gData);
    52                 if (dst != NULL) {
    53                         memcpy(dst, data.data(), data.size());
    54                         GlobalUnlock(gData);
    55                 }
    56                 else {
    57                         GlobalFree(gData);
    58                         gData = NULL;
    59                 }
    60         }
     48        return CFI_HANDLE;
     49}
    6150
    62         return gData;
     51ULONG
     52CPMClipboardBitmapConverter::fromIClipboard(const CString& data) const
     53{
     54    /*
     55     * We're getting a windows DIB, create a PM bitmap from that.
     56     */
     57    /** @todo implement me */
     58    return 0;
    6359}
    6460
    6561CString
    66 CMSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
     62CPMClipboardBitmapConverter::toIClipboard(ULONG data) const
    6763{
     64#if 1
     65    /** @todo implement me */
     66    return CString();
     67#else
     68    HBITMAP hbmp = (HBITMAP)data;
     69
     70    BITMAPINFOHEADER2 BmpHdr;
     71
     72    ULONG        cbFix;
     73    ULONG        cx;
     74    ULONG        cy;
     75    USHORT cPlanes;
     76    USHORT cBitCount;
     77    ULONG        ulCompression;
     78    ULONG        cbImage;
     79    ULONG        cxResolution;
     80    ULONG        cyResolution;
     81    ULONG        cclrUsed;
     82    ULONG        cclrImportant;
     83    USHORT usUnits;
     84    USHORT usReserved;
     85    USHORT usRecording;
     86    USHORT usRendering;
     87    ULONG        cSize1;
     88    ULONG        cSize2;
     89    ULONG        ulColorEncoding;
     90    ULONG        ulIdentifier;
     91
     92    if (GpiQueryBitmapInfoHeader(hbmp, &BmpHdr)) {
     93        LOG((CLOG_INFO "bitmap: %dx%d %d", bmpData.biWidth, bitmap->bmiHeader.biHeight, (int)bitmap->bmiHeader.biBitCount));
     94        if (    BmpHdr.cPlanes == 1
     95            &&  (BmpHdr.cBitsCount == 32 || BmpHdr.cBitsCount == 24 /*???*/)
     96            &&   BmpHdr.ulCompression == ) {
     97            // already in canonical form
     98            char *abImage = new char[BmpHdr.cbImage];
     99            /* fun stuff starts here. */
     100            //if (GipQueryBitmapBits() {
     101            }
     102            CString image(abImage, srcSize);
     103            delete abImage;
     104            return image;
     105        }
     106       
     107    }
     108    return CString();
     109
    68110        // get datator
    69111        const char* src = (const char*)GlobalLock(data);
     
    113155                        (bitmap->bmiHeader.biBitCount == 16 ||
    114156                        bitmap->bmiHeader.biBitCount == 32)) {
    115                         srcBits += 3 * sizeof(DWORD);
     157                        srcBits += 3 * sizeof(ULONG);
    116158                }
    117159        }
     
    144186
    145187        return image;
     188#endif
    146189}
     190
Note: See TracChangeset for help on using the changeset viewer.