Beispiel #1
0
Handle
Widget_shape( Handle self, Bool set, Handle mask)
{
    if ( var-> stage > csFrozen) return nilHandle;

    if ( !set) {
        if ( apc_widget_get_shape( self, nilHandle)) {
            HV * profile = newHV();
            Handle i = Object_create( "Prima::Image", profile);
            sv_free(( SV *) profile);
            apc_widget_get_shape( self, i);
            --SvREFCNT( SvRV((( PAnyObject) i)-> mate));
            return i;
        } else
            return nilHandle;
    }

    if ( mask && !kind_of( mask, CImage)) {
        warn("RTC008A: Illegal object reference passed to Widget::shape");
        return nilHandle;
    }

    if ( mask && (( PImage( mask)-> type & imBPP) != imbpp1)) {
        Handle i = CImage( mask)-> dup( mask);
        ++SvREFCNT( SvRV( PImage( i)-> mate));
        CImage( i)-> set_conversion( i, ictNone);
        CImage( i)-> set_type( i, imBW);
        apc_widget_set_shape( self, i);
        --SvREFCNT( SvRV( PImage( i)-> mate));
        Object_destroy( i);
    } else
        apc_widget_set_shape( self, mask);

    return nilHandle;
}
void lload::CImageController::LoadBack(size_t position)
{
	for (size_t i = 0;
		(i < m_scrollPosition - position) && (m_fileFramePosition + m_currentCollection.GetSize() < m_files.size());
		i++, m_fileFramePosition++)
	{
		m_currentCollection.AddBack(CImage(m_files[m_fileFramePosition + m_currentCollection.GetSize()]));
	}
	CorrectCollectionSize();
}
Beispiel #3
0
/////////////////////////////////////////////////////////////
/// Constructeur
///
/// \param Size :        Dimensions de la texture
/// \param Format :      Format de pixel de la texture
/// \param HasMipmaps :  Indique si la texture a des niveaux de mip
/// \param AutoMipmaps : Indique si la texture peut générer ses mips en HW
/// \param Texture :     ID de la texture GL
///
////////////////////////////////////////////////////////////
GLTexture::GLTexture(
	const Vector2I& Size, 
	PixelFormat::TPixelFormat Format, 
	bool HasMipmaps, 
	bool AutoMipmaps, 
	unsigned int Texture,
	const unsigned char *pData_) :
		ITextureBase(Size, Format, HasMipmaps, AutoMipmaps),
		m_Texture   (Texture)
{
	if (pData_ != nullptr)
	{
		m_Data.CopyImage(CImage(Size, Format, pData_));
	}
}
Beispiel #4
0
/////////////////////////////////////////////////////////////
/// Constructeur
///
/// \param Size :        Dimensions de la texture
/// \param Format :      Format de pixel de la texture
/// \param HasMipmaps :  Indique si la texture a des niveaux de mip
/// \param AutoMipmaps : Indique si la texture peut générer ses mips en HW
/// \param Texture :     ID de la texture Dx
///
////////////////////////////////////////////////////////////
DX9Texture::DX9Texture(
	const Vector2I& Size, 
	PixelFormat::TPixelFormat Format, 
	bool HasMipmaps, 
	bool AutoMipmaps, 
	IDirect3DTexture9* Texture,
	const unsigned char* pData_) :
		ITextureBase(Size, Format, HasMipmaps, AutoMipmaps),
		m_Texture(Texture)
{
	if (pData_ != nullptr)
	{
		m_Data.CopyImage(CImage(Size, Format, pData_));
		Update(CRectangle(0, 0, Size.x, Size.y));
	}
}
Beispiel #5
0
	//--------------------------------------------------------------------
	void CScrollBar::SetSlider( CBitmap& p_SliderBitmap )
	{
		m_pSlider = &p_SliderBitmap;

		if( m_eType == ESBT_Horizontal )
		{
			SetHeight( m_pSlider->Height() );
		}
		else
		{
			SetWidth( m_pSlider->Width() );
		}

		m_vecImages.push_back( CImage( SSGUIManager::Instance()->GetGraphics().CreateImage( 
			*m_pSlider, 0, 0, m_nWidth, m_nHeight, EBF_Smooth ) ) );
	}
Beispiel #6
0
	//--------------------------------------------------------------------
	void CAnimationCursor::Init( CBitmap& p_pBitmap, const std::wstring& p_szName,
		int p_nSingleWidth, int p_nSingleHeight )
	{
		m_pBitmap = &p_pBitmap;
		int nWidthLine = m_pBitmap->Width() / p_nSingleWidth;
		int nHeightLine = m_pBitmap->Height() / p_nSingleHeight;

		m_nMaxFrame = nWidthLine * nHeightLine;

		for( int i = 0; i < nWidthLine; ++i )
		{
			for( int j = 0; j < nHeightLine; ++j )
			{
				m_vecAnim.push_back( CImage( SSAnimationCursorManager::Instance()->GetGraphics().CreateImage( 
					*m_pBitmap, i * p_nSingleWidth, j * p_nSingleHeight,
					p_nSingleWidth, p_nSingleHeight, EBF_Tileable ) ) );
			}
		}
	}
static void GenSmallImage( int img_count, CImage &back, const RectF &render_rect, int sel, CImage &img_alpha )
{
#define RAND_ALPHA ( ( 130 + random( 50 ) ) / 255.0f )
#define ROT_ANGLE ( random( 20 ) + 160 )
    if( img_count < 1 )
    {
        return ;
    }

    CFileListManager &file_manager = GetInst( CFileListManager );

    const Range &alpha_r = GetInst( CConfiger ).GetSystem().AnswerAlphaRange;
    float fAnswerAlpha = ( random( alpha_r.second - alpha_r.first ) + alpha_r.first ) / 255.0f;
    CImage img_first;
    CreateImgFromBuffer( file_manager.GetRandSmall(), img_first, true );
    float fFirstRot = ROT_ANGLE;
    float fFirstAlpha = RAND_ALPHA;
    PointF pos = RotateImage( img_first, img_alpha, img_count == 1 ? ( random( 60 ) - 30.0f ) : fFirstRot );
    PointF render_pos = GetRandPosInULRect( img_first.GetWidth(), img_first.GetHeight(), render_rect );
    RectF img_rect( render_pos.X + 20, render_pos.Y + 20, img_first.GetWidth() - 40, img_first.GetHeight() - 40 );
    back.AlphaBlend( &img_first, render_pos.X, render_pos.Y,
                     img_count == 1 ? fAnswerAlpha : fFirstAlpha );

    CImage *img_cover = NULL;
    PointF rot_pos = GetRotPos( img_alpha, pos );
    float fRotQuo = 20.0f;
    float fAlphaQuo = -0.08f;
    for( int i = 1; i < img_count; ++ i, fRotQuo += fRotQuo, fAlphaQuo += fAlphaQuo )
    {
        img_cover = MP_NEW CImage();
        CreateImgFromBuffer( file_manager.GetRandSmall(), *img_cover, true );
        img_cover->RotateEx( fFirstRot + fRotQuo, rot_pos.X, rot_pos.Y );
        img_cover->SetAlphaMap( &img_alpha, pos.X, pos.Y );
        back.AlphaBlend( img_cover, render_pos.X, render_pos.Y, fFirstAlpha + fAlphaQuo );
        MP_DELETE(img_cover);
    }

    BlendSelSign( back, img_rect, sel );
}
Beispiel #8
0
void CFrame::OnEditPaste() 
{
   CImageDoc* pDoc = (CImageDoc*)CApp::GetApp().demoTemplate->OpenDocumentFile(NULL); 
   BOOL bOK = (pDoc != NULL);
	if (bOK)
   {
      bOK = OpenClipboard();
      if (bOK)
      {
			CImage((HBITMAP)::GetClipboardData(CF_BITMAP)).Detach(&pDoc->m_image);
         ::CloseClipboard();

		   CString str;
		   str.Format(_T("Clipboard Image %d"),CApp::GetApp().m_nDocCount++);
		   pDoc->SetTitle(str);
         pDoc->UpdateAllViews(NULL, CImageDoc::ENUM_hint_newimage);
		   
		   str.Format(_T("(%dx%dx%d)"),pDoc->GetImage().GetWidth(),pDoc->GetImage().GetHeight(),pDoc->GetImage().GetBPP());
		   CStatusBar& statusBar = GetStatusBar();
		   statusBar.SetPaneText(2, str);
      }
	}
}
CQuestionManager::Question CQuestionManager::GenOneQuestion()
{
    Question ques = { { 0 }, 0 };
    CFileListManager &file_manager = GetInst( CFileListManager );
    int r = 0;

    // alpha image
    CImage img_alpha;
    CreateImgFromBuffer( file_manager.GetAlpha(), img_alpha );

    // 1.generate the background.
    CImage back;
    CreateImgFromBuffer( file_manager.GetRandBack(), back );
    r = random( 3 );
    CImage *img_cover;
    for( int i = 0; i < r; ++ i )
    {
        img_cover = MP_NEW CImage();
        CreateImgFromBuffer( file_manager.GetRandBack(), *img_cover );
        back.AlphaBlend( img_cover, 0, 0, ( random( 55 ) + 100 ) / 255.0f );
        MP_DELETE(img_cover);
    }

    // 2.generate small pictures.
    ques.answer = BlendSmallImage( back, img_alpha );

    // 3.covert the image to raw buffer.
    if( !back.ExportJpegToMemory( (BYTE*&) ques.data.buf, (DWORD&) ques.data.size, 85 ) )
    {
        ques.data.buf = 0;
        ques.data.size = 0;
        PutoutLog( LOG_FILE, LT_ERROR, "Export jpeg failed." );
    }

    DumpImage( &back );
    return ques;
}
void CaptureThread::run()
{
    while(1)
    {
        // Check if it is paused
        pauseMutex.lock();
        if (paused)
        {
            pauseMutex.unlock();
            sleep(3); // to avoid consuming CPU
            continue;
        }
        pauseMutex.unlock();

        /////////////////////////////////
        // Stop thread if stopped=TRUE //
        /////////////////////////////////
        stoppedMutex.lock();
        if (stopped)
        {
            stopped = false;
            stoppedMutex.unlock();
            break;
        }
        stoppedMutex.unlock();


        // Capture a frame
        capMutex.lock();
            cap >> grabbedFrame;
        capMutex.unlock();
        // resize the frame to fit in the UI frames
        cv::resize(grabbedFrame, grabbedFrame, cv::Size(toResize.width(), toResize.height()));
        // flip the image
        cv::flip(grabbedFrame, grabbedFrame, 1);

        // Create the CImage object
        currentImage = CImage(grabbedFrame.clone());

        // add the frame to the buffer
        inputBuffer->addFrame(currentImage);

        // if the video reached the end just repeat it
        inputMutex.lock();
        if (inputMode == INPUT_VIDEO)
        {
            inputMutex.unlock();
            capMutex.lock();
            if (cap.get(CV_CAP_PROP_FRAME_COUNT)-1 == cap.get(CV_CAP_PROP_POS_FRAMES))
            {
                cap.set(CV_CAP_PROP_POS_FRAMES, 0);
                emit videoFinished();
            }
            capMutex.unlock();
            msleep(1000/cap.get(CV_CAP_PROP_FPS));
        }
        else if (inputMode == INPUT_CAMERA)
        {
            inputMutex.unlock();
            msleep(35);
        }
        inputMutex.unlock();
    }
}
Beispiel #11
0
	//--------------------------------------------------------------------
	void CWinControl::SetBG( CBitmap& p_bBackground )
	{
		m_pBackGround = &p_bBackground;
		m_vecImage.push_back( CImage( SSGUIManager::Instance()->GetGraphics().CreateImage( 
			*m_pBackGround, 0, 0, m_pBackGround->Width(), m_pBackGround->Height(), EBF_Smooth ) ) );
	}