コード例 #1
0
ファイル: imgResizer.c プロジェクト: ferrasrl/easyHand
static void TextProcessor(INT hdlImage,CHAR *lpText)
{
	BYTE *lp;
	CHAR szTesto[1024];
	POINT pt;
	IMGHEADER *Img;
	HDC hDC,hDClone;
	HBITMAP hbCopy;
	BYTE *lpSorg;
	INT iLx,iLy;
	BITMAPINFOHEADER *BmpHeader;
	BITMAPINFO *BmpInfo;
	INT iAlt=12;
	INT iCol1=0;
	INT iCol2=-1;
	BOOL fBold=FALSE;

	// ----------------------------------------------------------------------------
	// Creo una zona di memoria tipo video delle dimensioni dell'immagine
	//
	//memcpy(&ImgHeader,memoLock(hdlImage),sizeof(IMGHEADER));
	printf("Elaborazione TextProcessor [%s]" CRLF,lpText); //Sleep(2000);
	//ehLogWrite("> %s" CRLF,lpText);
	if (!*lpText) return;

	Img=memoLock(hdlImage);
	BmpInfo=(BITMAPINFO *) &Img->bmiHeader;
	BmpHeader=(BITMAPINFOHEADER *) &Img->bmiHeader;
    iLy=BmpHeader->biHeight; if (iLy<0) iLy=-BmpHeader->biHeight;
    iLx=BmpHeader->biWidth;

    hDC=GetDC(NULL); hDClone=CreateCompatibleDC(hDC); 
	SetMapMode(hDClone, MM_TEXT);
	hbCopy = CreateCompatibleBitmap(hDC, iLx, iLy);
	SelectObject(hDClone, hbCopy);
	ReleaseDC(NULL,hDC);

    lpSorg=(BYTE *) Img;  lpSorg+=Img->Offset;

	// Scrivo l'immagine in questa zona di memoria
	if (StretchDIBits(hDClone, 
					  // Coordinate e dimensioni di stampa a video
					  0,0,
					  iLx, 
					  iLy,

					  // Coordinate e dimensioni di lettura nel sorgente
					  0,
					  iLy+1,
					  iLx,
					  -iLy,
					  lpSorg,
					  (BITMAPINFO *) &Img->bmiHeader,
					  DIB_RGB_COLORS, 
					  SRCCOPY) == GDI_ERROR) {printf("StretchDIBits Failed");}

	// Ci faccio quello che ci devo fare con i comandi
	lp=strtok(lpText,"|");
	*szTesto=0;
	ZeroFill(pt);
	while (lp)
	{
		//printf("[%s]" CRLF,lp); 

		if (!memcmp(lp,"TEXT=",5)) strcpy(szTesto,lp+5);
		if (!memcmp(lp,"PX=",3)) pt.x=atoi(lp+3);
		if (!memcmp(lp,"PY=",3)) pt.y=atoi(lp+3);
		if (!memcmp(lp,"ALT=",3)) iAlt=atoi(lp+3);
		if (!memcmp(lp,"COL=",4)) iCol1=ColorConvert(lp+4);
		if (!memcmp(lp,"BG=",3)) iCol2=ColorConvert(lp+3);
		if (!memcmp(lp,"BOLD=",5)) fBold=atoi(lp+5);
		
		if (*lp=='*') 
		{
			//printf("Stampo: %d,%d,%s" CRLF,pt.x,pt.y,szTesto);
			//ehLogWrite("Stampo: %d,%d,%s",pt.x,pt.y,szTesto);
			LPrint(hDClone,pt.x,pt.y,iCol1,iCol2,"Arial",iAlt,fBold,szTesto);
		}

		lp=strtok(NULL,"|");
	}

	// Mi riprendo la zona di memoria video e la rimetto nell'immagine
	//BmpHeader->biHeight*=-1;
	GetDIBits(
		hDClone,           // handle to device context
		hbCopy,      // handle to bitmap
		0,   // first scan line to set in destination bitmap
		iLy,   // number of scan lines to copy
		lpSorg,    // address of array for bitmap bits
		(BITMAPINFO *) &Img->bmiHeader, // address of structure with bitmap data
		DIB_RGB_COLORS        // RGB or palette index
		);
	
	if (!DeleteDC(hDClone)) 
	{
		ehLogWrite("Errore in cancellazione DC %d",GetLastError());
		ehExit("Errore in cancellazione DC");
	}

	if (!DeleteObject(hbCopy))
	{
		ehLogWrite("Errore in cancellazione Bitmap %d",GetLastError());
		ehExit("Errore in cancellazione Bitmap");
	}

	memoUnlockEx(hdlImage,"A5");
	IMGMirrorY(hdlImage);
	
	// Libero le risorse

	//TextOut(


}
コード例 #2
0
JERRCODE CJPEGDecoder::DecodeScanBaselineIN_RSTI(void)
{
  int rcount = 0;
  IppStatus status;
  JERRCODE  jerr;
#ifdef __TIMING__
  Ipp64u   c0;
  Ipp64u   c1;
#endif

#ifdef _OPENMP
  int j;
  for(j = 0; j < m_num_threads; j++)
    status = ippiDecodeHuffmanStateInit_JPEG_8u(m_state_t[j]);
#endif
  status = ippiDecodeHuffmanStateInit_JPEG_8u(m_state);

  if(ippStsNoErr != status)
  {
    return JPEG_ERR_INTERNAL;
  }

  m_marker = JM_NONE;

  // workaround for 8-bit qnt tables in 12-bit scans
  if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 0 && m_jpeg_precision == 12)
    m_qntbl[0].ConvertToHighPrecision();

  if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 0 && m_jpeg_precision == 12)
    m_qntbl[1].ConvertToHighPrecision();

  if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 0 && m_jpeg_precision == 12)
    m_qntbl[2].ConvertToHighPrecision();

  if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 0 && m_jpeg_precision == 12)
    m_qntbl[3].ConvertToHighPrecision();

  // workaround for 16-bit qnt tables in 8-bit scans
  if(m_qntbl[0].m_initialized && m_qntbl[0].m_precision == 1 && m_jpeg_precision == 8)
    m_qntbl[0].ConvertToLowPrecision();

  if(m_qntbl[1].m_initialized && m_qntbl[1].m_precision == 1 && m_jpeg_precision == 8)
    m_qntbl[1].ConvertToLowPrecision();

  if(m_qntbl[2].m_initialized && m_qntbl[2].m_precision == 1 && m_jpeg_precision == 8)
    m_qntbl[2].ConvertToLowPrecision();

  if(m_qntbl[3].m_initialized && m_qntbl[3].m_precision == 1 && m_jpeg_precision == 8)
    m_qntbl[3].ConvertToLowPrecision();

  if(m_dctbl[0].IsEmpty())
  {
    jerr = m_dctbl[0].Create();
    if(JPEG_OK != jerr)
      return jerr;

    jerr = m_dctbl[0].Init(0,0,(Ipp8u*)&DefaultLuminanceDCBits[0],(Ipp8u*)&DefaultLuminanceDCValues[0]);
    if(JPEG_OK != jerr)
      return jerr;
  }

  if(m_dctbl[1].IsEmpty())
  {
    jerr = m_dctbl[1].Create();
    if(JPEG_OK != jerr)
      return jerr;

    jerr = m_dctbl[1].Init(1,0,(Ipp8u*)&DefaultChrominanceDCBits[0],(Ipp8u*)&DefaultChrominanceDCValues[0]);
    if(JPEG_OK != jerr)
      return jerr;
  }

  if(m_actbl[0].IsEmpty())
  {
    jerr = m_actbl[0].Create();
    if(JPEG_OK != jerr)
      return jerr;

    jerr = m_actbl[0].Init(0,1,(Ipp8u*)&DefaultLuminanceACBits[0],(Ipp8u*)&DefaultLuminanceACValues[0]);
    if(JPEG_OK != jerr)
      return jerr;
  }

  if(m_actbl[1].IsEmpty())
  {
    jerr = m_actbl[1].Create();
    if(JPEG_OK != jerr)
      return jerr;

    jerr = m_actbl[1].Init(1,1,(Ipp8u*)&DefaultChrominanceACBits[0],(Ipp8u*)&DefaultChrominanceACValues[0]);
    if(JPEG_OK != jerr)
      return jerr;
  }

  m_rsti_offset[0] = m_BitStreamIn.GetStreamPos();

#ifdef _OPENMP
#pragma omp parallel shared(rcount) if(m_jpeg_sampling != JS_411)
#endif
  {
    int     i          = 0;
    int     rh         = 1;
    int     r          = 0;
    int     currMCURow = 0;
    int     idThread   = 0;
    Ipp16s* pMCUBuf    = 0;  // the pointer to Buffer for a current thread.

#ifdef _OPENMP
    idThread = omp_get_thread_num(); // the thread id of the calling thread.
#endif

    pMCUBuf = m_block_buffer + idThread * m_numxMCU * m_nblock * DCTSIZE2;

    while(i < m_num_rsti)
    {
#ifdef _OPENMP
#pragma omp critical
      {
#endif

        i = rcount;
        rcount++;

        if(i < m_num_rsti)
        {
          ParseNextRSTI(idThread,i+1);
        }

#ifdef _OPENMP
      }
#endif

      if(i < m_num_rsti)
      {
#ifdef _OPENMP

        currMCURow = m_rsti_height*i;

        m_BitStreamInT[idThread].SetDataLen(m_rsti_offset[i+1] - m_rsti_offset[i]);
        m_BitStreamInT[idThread].SetCurrPos(0);
#endif
        rh = IPP_MIN(m_rsti_height, m_numyMCU - currMCURow);

        for(r = 0; r < rh; r++)
        {
          ippsZero_16s(pMCUBuf,m_numxMCU * m_nblock * DCTSIZE2);

          jerr = DecodeHuffmanMCURowBL_RSTI(pMCUBuf, idThread);
          if(JPEG_OK != jerr)
            continue;

          jerr = ReconstructMCURowBL8x8(pMCUBuf, idThread);
          if(JPEG_OK != jerr)
            continue;

          jerr = UpSampling(currMCURow + r,idThread);
          if(JPEG_OK != jerr)
            continue;

          jerr = ColorConvert(currMCURow + r,idThread);
          if(JPEG_OK != jerr)
            continue;
        }

        if(m_jpeg_restart_interval)
        {
          jerr = ProcessRestart(idThread);
          if(JPEG_OK != jerr)
          {
            LOG0("Error: ProcessRestart() failed!");
          }
        }
      } // if
#ifndef _OPENMP
        i++;
#endif
    } // for m_numyMCU
  } // OMP

#ifdef _OPENMP
  /*for(j = 0; j < m_num_rsti; j++)
  {
    omp_destroy_lock(&locks[j]);
  }

  ippFree(locks);
  locks = 0;*/
#endif

  return JPEG_OK;
} // CJPEGDecoder::DecodeScanBaselineIN_RSTI()