예제 #1
0
QString KWord13Picture::getOasisPictureName( void ) const
{
    if ( ! m_valid || ! m_tempFile )
        return QString();
        
    // We need a 32 digit hex value of the picture number
    // Please note: it is an exact 32 digit value, truncated if the value is more than 512 bits wide. :-)
    QString number;
    number.fill('0',32);
    // ### TODO: have a real counter instead of using the pointers
    number += QString::number( (long long)( (void*) m_tempFile ) , 16 ); // in hex

    QString strExtension( m_storeName.lower() );
    const int result = m_storeName.findRev( '.' );
    if ( result >= 0 )
    {
        strExtension = m_storeName.mid( result );
    }
    
    QString ooName( "Pictures/" );
    ooName += number.right( 32 );
    ooName += strExtension;

    return ooName;
}
예제 #2
0
bool CScene::OnProcessingWindowMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam)
{
    switch (nMessageID)
    {
    case WM_DROPFILES:
    {
        HDROP hDrop = (HDROP)wParam;
        TCHAR szPathFileName[MAX_PATH + 1];
        DragQueryFile(hDrop, 0, szPathFileName, MAX_PATH);

        if (m_cImage) {
            DeleteObject(m_cImage);
            m_cImage = nullptr;
        }
        if (m_hIcon) {
            DestroyIcon(m_hIcon);
            m_hIcon = nullptr;
        }

        std::wstring strExtension(PathFindExtension(szPathFileName));
        if (   strExtension == TEXT(".png")
                || strExtension == TEXT(".jpg")
                || strExtension == TEXT(".bmp")
                || strExtension == TEXT(".jpeg")
                || strExtension == TEXT(".PNG")
                || strExtension == TEXT(".JPG")
                || strExtension == TEXT(".JPEG")
                || strExtension == TEXT(".BMP")
           )
        {
            CImage m_cImageSumnail;
            m_cImageSumnail.Load(szPathFileName);

            float height = (float)m_cImageSumnail.GetHeight();
            float width = (float)m_cImageSumnail.GetWidth();
            bool bStand = false;
            int space = 0;
            if (height > width) {
                bStand = true;
                width /= height;
                height = 1;
            }
            else if (height < width) {
                bStand = false;
                height /= width;
                width = 1;
            }
            else {
                height = width = 1;
            }

            height *= 64.f;
            width *= 64.f;

            space = 32 - (bStand ? width : height) * 0.5f;

            CImage cImage;
            cImage.Create(64, 64, 32, CImage::createAlphaChannel);

            HDC hdc = cImage.GetDC();
            RECT rc = { 0,0,64,64 };
            SetDCBrushColor(hdc, RGB(255, 0, 255));
            FillRect(hdc, &rc, (HBRUSH)GetStockObject(DC_BRUSH));
            if (bStand)	m_cImageSumnail.TransparentBlt(hdc, int(space), 0, int(width), int(height), RGB(255, 0, 255));
            else		m_cImageSumnail.TransparentBlt(hdc, 0, int(space), int(width), int(height), RGB(255, 0, 255));
            cImage.ReleaseDC();

            ///////////////////////////////////////////////////////

            BITMAPINFO m_bif;
            ZeroMemory(&m_bif, sizeof(BITMAPINFO));

            // 비트맵(DDB) 정보 얻기
            BITMAP bmp;
            GetObject(cImage, sizeof(BITMAP), &bmp);

            // 비트맵(DIB) 정보 설정
            BITMAPINFOHEADER& bmih = m_bif.bmiHeader;
            ZeroMemory(&bmih, sizeof(BITMAPINFOHEADER));
            bmih.biSize = sizeof(BITMAPINFOHEADER);
            bmih.biWidth = bmp.bmWidth;    // 가로
            bmih.biHeight = bmp.bmHeight;  // 세로
            bmih.biPlanes = 1;
            bmih.biBitCount = cImage.GetBPP();          // 픽셀당 비트수(BPP)
            bmih.biCompression = BI_RGB;

            // 비트맵(DIB) 데이터 추출
            // 데이터의 크기를 알아낸다
            HDC hDC = GetDC(NULL);
            GetDIBits(hDC, cImage, 0, bmp.bmHeight, NULL,
                      (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);

            DWORD m_dwImageSize = bmih.biSizeImage;

            // 데이터 저장 공간 확보
            LPBYTE m_bytes = new BYTE[m_dwImageSize];
            GetDIBits(hDC, cImage, 0, bmp.bmHeight, m_bytes, (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);
            ReleaseDC(NULL, hDC);

            size_t cnt = 0;
            for (int y = 0; y < m_bif.bmiHeader.biHeight; y++)  for (int x = 0; x < m_bif.bmiHeader.biWidth; x++)
                {
                    if (!(m_bytes[cnt] == 255 && m_bytes[cnt + 1] == 0 && m_bytes[cnt + 2] == 255))
                        m_bytes[cnt + 3] = 255;
                    cnt += 4;
                }

            LPVOID pNewBytes;
            m_cImage = ::CreateDIBSection(NULL, &m_bif, DIB_RGB_COLORS, &pNewBytes, 0, 0);

            hDC = GetDC(NULL);

            SetDIBits(hDC, m_cImage, 0, m_bif.bmiHeader.biHeight, m_bytes, &m_bif, DIB_RGB_COLORS);

            ReleaseDC(NULL, hDC);


            m_cImageSumnail.Destroy();
            cImage.Destroy();
            delete[] m_bytes;


        }
        else
        {
            SHFILEINFO sfi;
            ZeroMemory(&sfi, sizeof(SHFILEINFO));
            SHGetFileInfo(szPathFileName, 0, &sfi, sizeof(SHFILEINFO),
                          SHGFI_USEFILEATTRIBUTES | SHGFI_ICON | SHGFI_SYSICONINDEX | SHGFI_TYPENAME);

            m_hIcon = sfi.hIcon;

        }
    }
    default:
        return false;
    }
    return true;
}