home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- //
- // CSurView.cpp : Implementation of the CSurroundView class
- //
- /////////////////////////////////////////////////////////////////////////////
- //
- // (C) Copyright Black Diamond Consulting, Inc 1996. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that Black
- // Diamond Consulting has no warranty obligations or liability
- // for any Sample Application Files which are modified.
- //
- // Revision History:
- //
- /////////////////////////////////////////////////////////////////////////////
-
- #include "stdafx.h"
- #include "dib.h"
- #include "resource.h"
-
- #ifndef _Surround_H_
- #include "Surround.h"
- #endif
-
- #ifndef __CSURVIEW_H__
- #include "CSurView.h"
- #endif
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- #define LOSHORT(l) ((SHORT)(l))
- #define HISHORT(l) ((SHORT)(((DWORD)(l) >> 16) & 0xFFFF))
-
- /////////////////////////////////////////////////////////////////////////////
- // CSurroundView
- IMPLEMENT_DYNAMIC( CSurroundView, CView )
-
- BEGIN_MESSAGE_MAP( CSurroundView, CView )
- //{{AFX_MSG_MAP(CSurroundView)
- ON_WM_TIMER()
- ON_WM_SETCURSOR()
- ON_WM_LBUTTONDOWN()
- ON_WM_KEYDOWN()
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CSurroundView construction/destruction
- CSurroundView::CSurroundView()
- {
- m_pSV = NULL; // No View
- m_hPalette = NULL; // No palette
- m_hOffscreenBitmap = NULL; // No offscreen bitmap
-
- m_zoomInKey = VK_SHIFT; // Default zoom in key
- m_zoomOutKey = VK_CONTROL; // Default zoom out key
-
- this->Reset();
- }
-
- CSurroundView::~CSurroundView()
- {
- this->Reset();
- }
-
- void CSurroundView::Reset()
- {
- // Release any view we may have
- if( m_pSV != NULL )
- {
- m_pSV->Release( );
- m_pSV = NULL;
- }
-
- // Delete possible palette
- if( m_hPalette != NULL )
- {
- DeleteObject( m_hPalette );
- m_hPalette = NULL;
- }
-
- // Delete possible offscreen bitmap
- if( m_hOffscreenBitmap != NULL )
- {
- DeleteObject( m_hOffscreenBitmap );
- m_hOffscreenBitmap = NULL;
- }
-
- // Set default location
- m_location.longitude = 0;
- m_location.latitude = 0;
-
- // Size of view
- m_size.cx = m_size.cy = 0;
-
- // Zoom Ratio of 1
- m_fZoom = 1.0f;
-
- // Set default cursor
- m_cursorID = 0;
-
- }
-
- void CSurroundView::SetZoomKeys( int zoomInKey, int zoomOutKey )
- {
- m_zoomInKey = zoomInKey;
- m_zoomOutKey = zoomOutKey;
- }
-
- void CSurroundView::OnDraw(CDC* pDC)
- {
- CRect rect;
- CRect rectSrc;
- HDC hdc;
-
- // If we don't have a view, just paint the background black
- if( m_pSV == NULL )
- {
- GetClientRect( &rect );
- pDC->FillRect( rect, CBrush::FromHandle((HBRUSH)::GetStockObject(BLACK_BRUSH)) );
- return;
- }
-
- if( m_viewExtents.right == MAX_ARCSECONDS ) // 360 image
- {
- if (m_location.longitude < 0)
- m_location.longitude = MAX_ARCSECONDS + (m_location.longitude % MAX_ARCSECONDS);
- else if (m_location.longitude > MAX_ARCSECONDS)
- m_location.longitude %= MAX_ARCSECONDS;
- }
- else // < 360 image
- {
- // Range check horizontal pan
- if( m_location.longitude < m_viewExtents.left )
- m_location.longitude = m_viewExtents.left;
- else if( m_location.longitude > m_viewExtents.right )
- m_location.longitude = m_viewExtents.right;
- }
-
- // Range check vertical pan
- if( m_location.latitude < m_viewExtents.top )
- m_location.latitude = m_viewExtents.top;
- else if( m_location.latitude > m_viewExtents.bottom )
- m_location.latitude = m_viewExtents.bottom;
-
- hdc = pDC->GetSafeHdc();
-
- // If we are using a palette, realize it
- if( m_hPalette != NULL )
- {
- ::SelectPalette( hdc, m_hPalette, FALSE );
- ::RealizePalette( hdc );
- }
-
- // Paint the image into our offscreen bitmap
- rect.SetRect( 0, 0, m_offscreenInfo.header.biWidth, m_offscreenInfo.header.biHeight );
- m_pSV->Draw( &m_location, &m_offscreenInfo.header, m_pOffscreenBits, &rect, 100 );
-
- GetClientRect( &rect );
-
- if( m_fZoom == 1.0 )
- {
- rectSrc = rect;
- }
- else
- {
- float newHeight = ((float)rect.Height()) / m_fZoom;
- float newWidth = ((float)rect.Width()) / m_fZoom;
-
- rectSrc.top = rect.top + (long)(((float)rect.Height() - newHeight) / 2);
- rectSrc.left = rect.left + (long)(((float)rect.Width() - newWidth) / 2);
- rectSrc.bottom = rectSrc.top + (long)newHeight;
- rectSrc.right = rectSrc.left + (long)newWidth;
- }
-
- StretchDIBits( hdc, rect.left, rect.top, rect.Width(), rect.Height(),
- rectSrc.left, rectSrc.top, rectSrc.Width(), rectSrc.Height(),
- m_pOffscreenBits, (BITMAPINFO *)&m_offscreenInfo, DIB_RGB_COLORS, SRCCOPY );
- }
-
- HPALETTE CSurroundView::CreateIdentityPalette( int nColors )
- {
- int i;
- int nStaticColors;
- int nUsableColors;
-
- //*** Initialize version number and # entries
- m_logicalPalette.version = 0x300;
- m_logicalPalette.numberOfEntries = 256;
-
- //*** Just use the screen DC where we need it
- HDC hdc = ::GetDC( NULL );
-
- //*** For SYSPAL_NOSTATIC, just copy the color table into
- //*** a PALETTEENTRY array and replace the first and last entries
- //*** with black and white
- //*** For SYSPAL_STATIC, get the twenty static colors into
- //*** the array, then fill in the empty spaces with the
- //*** given color table
-
- //*** Get the static colors from the system palette
-
- // if (GetSystemPaletteUse(hdc) == SYSPAL_NOSTATIC)
- if( TRUE )
- nStaticColors = 0;
- else
- nStaticColors = ::GetDeviceCaps( hdc, NUMCOLORS ) / 2;
-
- if( nStaticColors > 0 )
- {
- ::GetSystemPaletteEntries( hdc, 0, nStaticColors, m_logicalPalette.entries );
- ::GetSystemPaletteEntries( hdc, 256-nStaticColors, nStaticColors, m_logicalPalette.entries );
- }
-
- for( i = 0; i < nStaticColors; i++ )
- m_logicalPalette.entries[i].peFlags = 0;
-
- for( i = 0;i < nStaticColors; i++ )
- {
- // copy the system colors into the DIB header
- m_offscreenInfo.colors[i].rgbRed =
- m_logicalPalette.entries[i].peRed;
- m_offscreenInfo.colors[i].rgbGreen =
- m_logicalPalette.entries[i].peGreen;
- m_offscreenInfo.colors[i].rgbBlue =
- m_logicalPalette.entries[i].peBlue;
- m_offscreenInfo.colors[i].rgbReserved = 0;
-
- m_logicalPalette.entries[i].peFlags = 0;
-
- m_offscreenInfo.colors[256 - i].rgbRed =
- m_logicalPalette.entries[256 - i].peRed;
- m_offscreenInfo.colors[256 - i].rgbGreen =
- m_logicalPalette.entries[256 - i].peGreen;
- m_offscreenInfo.colors[256 - i].rgbBlue =
- m_logicalPalette.entries[256 - i].peBlue;
- m_offscreenInfo.colors[256 - i].rgbReserved = 0;
-
- m_logicalPalette.entries[256 - i].peFlags = 0;
- }
-
- //*** Fill in the entries from the given color table
- nUsableColors = nColors - nStaticColors;
-
- if( m_pSV != NULL )
- m_pSV->GetColors( i, nUsableColors, m_offscreenInfo.colors );
-
- for( ; i < nUsableColors; i++ )
- {
- m_logicalPalette.entries[i].peRed = m_offscreenInfo.colors[i].rgbRed;
- m_logicalPalette.entries[i].peGreen = m_offscreenInfo.colors[i].rgbGreen;
- m_logicalPalette.entries[i].peBlue = m_offscreenInfo.colors[i].rgbBlue;
- m_offscreenInfo.colors[i].rgbReserved = 0;
- m_logicalPalette.entries[i].peFlags = PC_NOCOLLAPSE;
- }
-
- //*** Mark any empty entries as PC_NOCOLLAPSE
- for( ; i < 256 - nStaticColors; i++ )
- m_logicalPalette.entries[i].peFlags = PC_NOCOLLAPSE;
-
- //*** Set the peFlags of the upper static colors to zero
- for( i = 256 - nStaticColors; i < 256; i++ )
- m_logicalPalette.entries[i].peFlags = 0;
-
- //*** Remember to release the DC!
- ::ReleaseDC( NULL, hdc );
-
- //*** Return the palette
- return ::CreatePalette( (LOGPALETTE *)&m_logicalPalette );
- }
-
- // GetMaxViewSize()
- //
- // Returns the maximum size of the client window for the current
- // Surround Video Image
- //
- void CSurroundView::GetMaxViewSize( SIZE* pSize )
- {
- ISurround* pISurround = this->GetISurround();
-
- if( pISurround != NULL )
- pISurround->GetMaxViewSize( 1.0f, pSize );
- else
- {
- pSize->cx = ::GetSystemMetrics( SM_CXFULLSCREEN );
- pSize->cy = ::GetSystemMetrics( SM_CYFULLSCREEN );
- }
- }
-
- BOOL CSurroundView::UpdateSurroundView()
- {
- CRect clientRect;
- SIZE maxViewSize;
-
- // Make sure there is an ISurround
- if( this->GetISurround() == NULL )
- return FALSE;
-
- // If we already have a view, release it
- if( m_pSV != NULL )
- {
- m_pSV->Release( );
- m_pSV = NULL;
- }
-
- // Calculate our view size based on current window size and max view size
- this->GetISurround()->GetMaxViewSize( 1.0f, &maxViewSize );
- GetClientRect( clientRect );
- m_size.cx = min( clientRect.Width(), maxViewSize.cx );
- m_size.cy = min( clientRect.Height(), maxViewSize.cy );
-
- this->GetISurround()->GetView( &m_size, 1.0f, 100, SV_TOTAL_CORRECTION, &m_pSV );
-
- if( m_pSV != NULL )
- {
- // Make sure our current location is valid
- // NOTE: The call to GetViewRange also sets our location to the center (horizon) of the image
- m_pSV->GetViewRange( &m_viewExtents, &m_location.latitude );
-
- if( m_location.longitude < m_viewExtents.left )
- m_location.longitude = m_viewExtents.left;
- else if( m_location.longitude > m_viewExtents.right )
- m_location.longitude = m_viewExtents.right;
-
- this->UpdateOffscreenBitmap();
-
- }
-
- return m_pSV != NULL;
- }
-
- void CSurroundView::UpdateOffscreenBitmap()
- {
-
- // Makes no sense if we don't have a view
- if( m_pSV == NULL )
- return;
-
- SIZE size;
- HDC hdc = ::GetDC( m_hWnd );
-
- // Delete any previous bitmap
- if( m_hOffscreenBitmap != NULL )
- DeleteObject( m_hOffscreenBitmap );
-
- // Get the size of the view
- m_pSV->GetSize( &size );
-
- // Initialize offscreen bitmap
- m_offscreenInfo.header.biSize = sizeof(BITMAPINFOHEADER);
- m_offscreenInfo.header.biPlanes = 1;
- m_offscreenInfo.header.biBitCount = m_pSV->GetDepth();
- m_offscreenInfo.header.biCompression = BI_RGB;
- m_offscreenInfo.header.biClrUsed = 0;
- m_offscreenInfo.header.biClrImportant = 0;
- m_offscreenInfo.header.biHeight = size.cy;
- m_offscreenInfo.header.biWidth = size.cx;
- m_offscreenInfo.header.biSizeImage = (DWORD)DibPitch(&m_offscreenInfo.header) *
- (DWORD)DibHeight(&m_offscreenInfo.header);
-
- // Note: Here we create an identity palette for images with 8 bits/pixel or less.
- // If the image is greater than 8 bits/pixel we don't need a palette unless
- // we have an 8 bit (or lower) display, in which case we use the system
- // halftone palette.
- if( m_hPalette != NULL )
- {
- DeleteObject(m_hPalette);
- m_hPalette = NULL;
- }
- if( m_offscreenInfo.header.biBitCount == 8 )
- m_hPalette = CreateIdentityPalette( 256 );
- else
- {
- if( GetDeviceCaps( hdc, BITSPIXEL ) <= 8 )
- m_hPalette = ::CreateHalftonePalette( hdc );
- }
-
- // Create the offscreen bitmap
- m_hOffscreenBitmap = CreateDIBSection( hdc, (BITMAPINFO*)&m_offscreenInfo, DIB_RGB_COLORS,
- &m_pOffscreenBits, NULL, 0 );
- ::ReleaseDC( m_hWnd, hdc );
- }
-
-
- void CSurroundView::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
-
- this->Reset();
- this->UpdateSurroundView();
-
- // Force OnGetMinMaxInfo of parent frame to get called.
- // this will cause us to get sized appropriately if need be
- RECT rect;
- this->GetParentFrame()->GetWindowRect( &rect );
- this->GetParentFrame()->MoveWindow( &rect, TRUE );
-
- }
-
- afx_msg void CSurroundView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
- this->UpdateSurroundView();
- }
-
- afx_msg BOOL CSurroundView::OnEraseBkgnd( CDC* pDC )
- {
- if( IsViewPresent() )
- return TRUE;
-
- RECT rect;
- GetClientRect( &rect );
- pDC->FillRect( &rect, CBrush::FromHandle((HBRUSH)::GetStockObject(BLACK_BRUSH)) );
- return TRUE;
- }
-
- afx_msg void CSurroundView::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
- {
- CView::OnKeyDown( nChar, nRepCnt, nFlags );
-
- float zoomIncrement = 1.02F;
-
- if( nChar == m_zoomInKey )
- {
- m_fZoom *= zoomIncrement;
- }
- else if (nChar == m_zoomOutKey)
- {
- m_fZoom /= zoomIncrement;
- }
- else
- return;
-
- if( m_fZoom >= 1.0F )
- this->Invalidate(FALSE);
- else
- m_fZoom = 1.0F;
-
- }
-
- void CSurroundView::ScrollImage( CPoint &anchorPoint, BOOL bLeftButton /* = TRUE */ )
- {
- MSG msg;
- CSize szDistance;
-
- // Set the anchor point
- m_anchorPoint = anchorPoint;
- ClientToScreen( &m_anchorPoint );
-
- // We are initially at Rest
- ::SetCursor( AfxGetApp()->LoadCursor(m_cursorID = IDC_REST) );
- szDistance.cx = 0;
- szDistance.cy = 0;
-
- // Capture the mouse
- SetCapture();
-
- // trap messages here until capture is lost or cancelled/accepted
- while( 1 )
- {
- if( ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
- {
- if( msg.message == WM_MOUSEMOVE )
- {
- CPoint ptCurrent;
- UINT oldCursorID;
-
- // If left mouse button isn't down, we're not suppose to be here
- if( !(msg.wParam & ((bLeftButton) ? MK_LBUTTON : MK_RBUTTON) ) )
- return;
-
- // Save the current cursor ID
- oldCursorID = m_cursorID;
-
- // Set current mouse point (We need signed values here)
- ptCurrent.x = LOSHORT(msg.lParam);
- ptCurrent.y = HISHORT(msg.lParam);
- ClientToScreen(&ptCurrent);
-
- if(m_anchorPoint.x == -1 && m_anchorPoint.y == -1)
- {
- m_cursorID = 0;
- szDistance.cx = 0;
- szDistance.cy = 0;
- }
- else
- {
- BOOL bCloseToXAxis = FALSE;
- BOOL bCloseToYAxis = FALSE;
-
- szDistance.cx = ptCurrent.x - m_anchorPoint.x;
- szDistance.cy = ptCurrent.y - m_anchorPoint.y;
-
- if( szDistance.cx == 0 && szDistance.cy == 0 )
- m_cursorID = IDC_REST;
- else
- {
- if( abs(szDistance.cx) < abs(szDistance.cy) )
- bCloseToYAxis = ( 5 * abs(szDistance.cx) < 2 * abs(szDistance.cy) );
- else if( abs(szDistance.cx) > abs(szDistance.cy) )
- bCloseToXAxis = (5 * abs(szDistance.cy) < 2 * abs(szDistance.cx) );
-
- if( bCloseToXAxis )
- m_cursorID = (szDistance.cx > 0) ? IDC_RIGHT : IDC_LEFT;
- else if(bCloseToYAxis)
- m_cursorID = (szDistance.cy > 0) ? IDC_DOWN : IDC_UP;
- else if( ptCurrent.x < m_anchorPoint.x )
- m_cursorID = ( ptCurrent.y < m_anchorPoint.y ) ? IDC_UL : IDC_DL;
- else if(ptCurrent.x > m_anchorPoint.x)
- m_cursorID = ( ptCurrent.y < m_anchorPoint.y ) ? IDC_UR : IDC_DR;
- }
- }
-
- // Change cursor if we need to
- if( m_cursorID != oldCursorID )
- ::SetCursor( AfxGetApp()->LoadCursor(m_cursorID) );
- }
- else if( msg.message == (UINT)((bLeftButton) ? WM_LBUTTONUP : WM_RBUTTONUP) )
- {
- ReleaseCapture();
- m_cursorID = 0;
- return;
- }
- else
- {
- DispatchMessage(&msg);
- }
-
- } // if( PeekMessage() )
-
- // If we need to move the image, do it
- if( szDistance.cx != 0 || szDistance.cy != 0 )
- {
- m_location.longitude += (ARCSECONDS)(((szDistance.cx * 120)/m_fZoom));
- m_location.latitude += (ARCSECONDS)(((szDistance.cy * (-120))/m_fZoom));
-
- CDC* pDC = GetDC();
- if( pDC != NULL )
- {
- this->OnDraw( pDC );
- ReleaseDC( pDC );
- }
- }
-
- } // end while( TRUE )
- }
-
- afx_msg void CSurroundView::OnLButtonDown( UINT nFlags, CPoint point )
- {
- // Scroll the image
- ScrollImage( point );
- }
-
- afx_msg BOOL CSurroundView::OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message )
- {
- if( m_cursorID != 0 )
- {
- ::SetCursor( AfxGetApp()->LoadCursor( m_cursorID ) );
- return TRUE;
- }
- return CView::OnSetCursor( pWnd, nHitTest, message );
- }
-
-
- HRESULT CSurroundView::SphereToView( LPSPHERE_POINT pLocation, LPPOINT pPoint )
- {
- if( m_pSV == NULL )
- return SV_E_INCOMPATIBLE_SURFACE;
-
- return m_pSV->SphereToView( pLocation, &m_location, pPoint );
- }
-
- HRESULT CSurroundView::SphereToView( LPSPHERE_POINT pLocation, LPSIZE pSize, LPRECT pRect )
- {
- HRESULT hr;
- POINT pt;
-
- if( m_pSV == NULL )
- return SV_E_INCOMPATIBLE_SURFACE;
-
- hr = m_pSV->SphereToView( pLocation, &m_location, &pt );
- if( FAILED(hr) )
- return hr;
-
- pt.x += m_size.cx >> 1;
- pt.y += m_size.cy >> 1;
-
- // Calculate the location of pRect in view coordinates
- pRect->top = pt.y - pSize->cy/2;
- pRect->left = pt.x - pSize->cx/2;
-
- // ...figure in the zoom factor
- pRect->left = (LONG)((float)m_size.cx*0.5F*(1.0F - m_fZoom)+m_fZoom*(float)pRect->left);
- pRect->top = (LONG)((float)m_size.cy*0.5F*(1.0F - m_fZoom)+m_fZoom*(float)pRect->top);
-
- // ...and finally, the size of the rect
- pRect->right = pRect->left + (LONG)((float)pSize->cx * m_fZoom);
- pRect->bottom = pRect->top + (LONG)((float)pSize->cy * m_fZoom);
-
- return S_OK;
- }
-
- HRESULT CSurroundView::ViewToSphere( LPPOINT pPoint, LPSPHERE_POINT pLocation )
- {
- if( m_pSV == NULL )
- return SV_E_INCOMPATIBLE_SURFACE;
-
- return m_pSV->ViewToSphere( pPoint, &m_location, pLocation );
- }
-
- HRESULT CSurroundView::ViewToSphere( LPRECT pRect, LPSPHERE_POINT pLocation, LPSIZE pSize )
- {
- POINT pt;
-
- if( m_pSV == NULL )
- return SV_E_INCOMPATIBLE_SURFACE;
-
- pSize->cx = (LONG)((float)(pRect->right - pRect->left) / m_fZoom);
- pSize->cy = (LONG)((float)(pRect->bottom - pRect->top) / m_fZoom);
-
- pRect->left = (LONG)(((float)pRect->left - (float)m_size.cx*0.5F*(1.0F - m_fZoom))/m_fZoom);
- pRect->top = (LONG)(((float)pRect->top - (float)m_size.cy*0.5F*(1.0F - m_fZoom))/m_fZoom);
-
- pt.x = pRect->left + pSize->cx / 2;
- pt.y = pRect->top + pSize->cy / 2;
-
- pt.x -= m_size.cx / 2;
- pt.y -= m_size.cy / 2;
-
- return m_pSV->ViewToSphere( &pt, &m_location, pLocation );
- }
-
- HGLOBAL CSurroundView::GetImage( LPSPHERE_POINT pLocation, LPSIZE pSize )
- {
- HGLOBAL hMemory;
- DWORD memSize;
- UINT depth;
- BITMAPINFOHEADER* pDib;
- ISurround* pISurround = this->GetISurround();
-
- if( pISurround == NULL )
- return NULL;
-
- // Get the depth if the image
- depth = pISurround->GetDepth();
-
- // Calculate memory size needed the DIB...
- // ... get the header...
- memSize = sizeof( BITMAPINFOHEADER );
-
- // ...add in the size of the color table
- if( depth == 8 )
- memSize += 256 * sizeof( RGBQUAD );
-
- // ...and the size of the image
- memSize += WIDTHBYTES( depth * pSize->cx ) * pSize->cy;
-
- hMemory = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, memSize );
- if( hMemory == NULL )
- return NULL;
-
- pDib = (BITMAPINFOHEADER*)GlobalLock( hMemory );
-
- pDib->biSize = sizeof( BITMAPINFOHEADER );
- pDib->biPlanes = 1;
- pDib->biBitCount = depth;
- pDib->biCompression = BI_RGB;
- pDib->biSizeImage = 0;
- pDib->biClrUsed = 0;
- pDib->biClrImportant = 0;
- pDib->biHeight = pSize->cy;
- pDib->biWidth = pSize->cx;
- FixBitmapInfo(pDib);
-
- pISurround->GetBits( pLocation, pSize, pDib, DibPtr(pDib) );
- if( depth == 8 )
- pISurround->GetColors( 0, 255, DibColors(pDib) );
-
- GlobalUnlock( hMemory );
-
- return hMemory;
- }
-
- BOOL CSurroundView::PutImage( PDIB pDib, LPSPHERE_POINT pLocation, LPSIZE pSize )
- {
- UINT depth;
- ISurround* pISurround = this->GetISurround();
- HRESULT hr;
-
- if( pISurround == NULL )
- return FALSE;
-
- // Get the depth if the image
- depth = pISurround->GetDepth();
-
- if( depth != pDib->biBitCount )
- return FALSE;
-
- hr = pISurround->SetBits( pLocation, pSize, pDib, DibPtr(pDib) );
-
- return FAILED(hr);
- }
-
- BOOL CSurroundView::CopyImage( LPSPHERE_POINT pLocation, LPSIZE pSize )
- {
-
- HGLOBAL hMemory;
-
- if( (hMemory = GetImage( pLocation, pSize )) == NULL )
- return FALSE;
-
- // Send the DIB to the clipboard
- if( ::OpenClipboard( AfxGetMainWnd()->GetSafeHwnd() ) )
- {
- // we need to get rid of any CF_BITMAPs
- ::EmptyClipboard();
- ::SetClipboardData( CF_DIB, hMemory );
- ::CloseClipboard();
- }
-
- return TRUE;
- }
-