⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prot.cpp

📁 又VC++实现的基于TWAIN的扫描仪图像输入处理软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			  {
                n4=n2%(2*pScanner->m_nDPI);
/*
				//A1 扫描仪的拼色程序:B、G、R--> lp3、lp2、lp1 / lp6、lp5、lp4
			    if(jiou1[n4]==0)//表示该点是偶数点
				{
			     *(lphmem2+3*n2)=*(unsigned char*)(lp3+3*n2);
		         *(lphmem2+3*n2+1)=*(unsigned char*)(lp2+3*n2+1);
		         *(lphmem2+3*n2+2)=*(unsigned char*)(lp1+3*n2+2);
				}
			    else//表示该点是奇数点
				{
                  *(lphmem2+3*n2)=*(unsigned char*)(lp6+3*n2);
		          *(lphmem2+3*n2+1)=*(unsigned char*)(lp5+3*n2+1);
		          *(lphmem2+3*n2+2)=*(unsigned char*)(lp4+3*n2+2);
				}
*/
				//A0 扫描仪的拼色程序:R、G、B--> lp1、lp2、lp3 / lp4、lp5、lp6
				if(jiou1[n4]==0)//表示该点是偶数点
				{
			     *(lphmem2+3*n2)=*(unsigned char*)(lp1+3*n2);
		         *(lphmem2+3*n2+1)=*(unsigned char*)(lp2+3*n2+1);
		         *(lphmem2+3*n2+2)=*(unsigned char*)(lp3+3*n2+2);
				}
			    else//表示该点是奇数点
				{
                  *(lphmem2+3*n2)=*(unsigned char*)(lp4+3*n2);
		          *(lphmem2+3*n2+1)=*(unsigned char*)(lp5+3*n2+1);
		          *(lphmem2+3*n2+2)=*(unsigned char*)(lp6+3*n2+2);
				}
			  }
 
		      lp1=lp1+pMem->BytesPerRow;
              lp2=lp2+pMem->BytesPerRow;
              lp3=lp3+pMem->BytesPerRow;
              lp4=lp4+pMem->BytesPerRow;
              lp5=lp5+pMem->BytesPerRow;
              lp6=lp6+pMem->BytesPerRow;

		      n2=0;
		      lpBits2=lpStart2;
			  memcpy(lpBits2,lp1,y1*pMem->BytesPerRow);
		      lpBits2=lpBits2+y1*pMem->BytesPerRow;
			}//end count%2==0
		
		   //数据写入到PHOTOSHOP缓冲区中	
	 	  char* pChar;
		  pChar = (char*)pMem->Memory.TheMem;
		  n2=0;
          memcpy(pChar,lphmem2,pMem->BytesWritten);
		  lphmem2=lphmem2+pMem->BytesWritten;
     	
		  bytesout+=pMem->BytesWritten;
  		  RowsWritten=bytesout/pMem->BytesPerRow;
          //判断扫描是否结束
		  if ((bi.biHeight-RowsWritten) == 0)
		  {
		    done = TRUE;
            Hour=time1.GetHour();
	        Minute=time1.GetMinute();
	        Second=time1.GetSecond();
            pTesttime->end(Hour,Minute,Second);
            pSetScanner->SCSI_End(huigui);
		  }  
		  LogMessage("Copied memory\r\n");
          twRc = TWRC_SUCCESS;
          
		  if(count%2!=0)
		  {
            GlobalUnlock(hmem1);
		    GlobalFree(hmem1);
		  }
		  else
		  {
		    GlobalUnlock(hbuffer1);
		    GlobalFree(hbuffer1);	
		  }
          count++;
	      LogMessage("Mem Success\r\n");
	   }//结束maxrow==0
	   else    //maxrow!=0;即可以至少送一行数据
	   {
		  pMem->Columns = bi.biWidth;
          pMem->XOffset = 0;
          pMem->YOffset =bytesout/pMem->BytesPerRow;
		
          LogMessage("Set structure\r\n");
            
          maxrows = pMem->Memory.Length/pMem->BytesPerRow;
          RowsWritten = bytesout/pMem->BytesPerRow;

	      if (maxrows >= bi.biHeight - RowsWritten)
		  {
		     pMem->BytesWritten = pMem->BytesPerRow * (bi.biHeight - RowsWritten);
		     pMem->Rows = bi.biHeight - RowsWritten;
		  }
          else
		  {
		     pMem->BytesWritten = pMem->BytesPerRow *maxrows;
             pMem->Rows = maxrows;
		  }
 
		 if(count==0)
		 {
		   pProgressCtrl = (CProgressCtrl *)pScanningProgress->GetDlgItem(IDC_PROGRESS1);
		   pProgressCtrl->SetRange(0,50);
          
		   hbuffer2 = GlobalAlloc(GHND, (pMem->Rows+y1)*pMem->BytesPerRow);
		   lpStart2=(LPSTR)GlobalLock(hbuffer2);
		   lpBits2=lpStart2;
   
           hbuffer3 = GlobalAlloc(GHND, (pMem->Rows+y1)*pMem->BytesPerRow);
		   lpStart4=(LPSTR)GlobalLock(hbuffer3);
		   lpBits4=lpStart4; 

		   if((int)((pMem->Rows+y1)*pMem->BytesPerRow)>nReadInBytes)
		   {
			 n1=((pMem->Rows+y1)*pMem->BytesPerRow)/nReadInBytes;
			 nReadInBytes0=((pMem->Rows+y1)*pMem->BytesPerRow)-n1*nReadInBytes;
		   }
		   else
		   {
			n1=0;
			nReadInBytes0=(pMem->Rows+y1)*pMem->BytesPerRow;
		   }
		 } //结束count==0
		 else  //count!=0;
		 {
		    if((int)((pMem->Rows)*pMem->BytesPerRow)>nReadInBytes)
			{
			   n1=((pMem->Rows)*pMem->BytesPerRow)/nReadInBytes;
			   nReadInBytes0=((pMem->Rows)*pMem->BytesPerRow)-n1*nReadInBytes;
			 }
		    else
			 {
			   n1=0;
			   nReadInBytes0=(pMem->Rows)*pMem->BytesPerRow;
			  }	
		}

	     nReadInBytes1=nReadInBytes/3;
		 nReadInBytes2=nReadInBytes0/3;
         
	 	 hbuffer1 = GlobalAlloc(GHND, nReadInBytes*n1+nReadInBytes0);
		 lpBits=(LPSTR)GlobalLock(hbuffer1);
		 lpBits1=lpBits;
		 lpStart1=lpBits;

	     //一次读入需要的数据
		 if(count==0)
		 {
	       while(n1>0)
		   {
			 //从SCSI接口读取数据
             downRow=nReadInBytes/pMem->BytesPerRow;
			 SCSI_Read1(lpBits,nReadInBytes,nReadInBytes1,downRow,count);
       
             n2=0;
			 lpBits1=lpStart1;
             memcpy(lpBits2,lpBits1,nReadInBytes);
			 lpBits2=lpBits2+nReadInBytes;

			 number2=number2+nReadInBytes;
             if(number2>=(number1*n6))
			 {
			   pProgressCtrl->OffsetPos((int)(number2/(number1*n6)+0.5));
               nPrePos=nPrePos+1;
               n6++;
			 }
			 n1--;
		   }
           if(nReadInBytes0!=0)
		   {
		     downRow=nReadInBytes0/pMem->BytesPerRow;
			 SCSI_Read1(lpBits,nReadInBytes0,nReadInBytes2,downRow,count);
             
			 n2=0;
			 lpBits1=lpStart1;

			 memcpy(lpBits2,lpBits1,nReadInBytes0);
		     lpBits2=lpBits2+nReadInBytes0;
             //移动进程条
		     number2=number2+nReadInBytes0;
             if(number2>=(number1*n6))
			 {
			  pProgressCtrl->OffsetPos((int)(number2/(number1*n6)+0.5));
              nPrePos=nPrePos+1;
              n6++;
			 }
		   }
       }
		  //计算行数,判断是否读完
          bytesout+=pMem->BytesWritten;
  		  RowsWritten=bytesout/pMem->BytesPerRow;
          
///////////////////////////////////////////////////////////////////
          if ((bi.biHeight-RowsWritten) ==0 &&count==0)
		  {
             //行拼之前,首先要进行奇偶拼,使得在一行,处理内存1中的数据
			 pinj();
			 //拼色并将数据写入到PHOTOSHOP缓冲区中,这是行拼
	         n2=0;
		     char* pChar;
		     pChar = (char*)pMem->Memory.TheMem;
      
		     lp1=lpStart2;
	         lp2=lp1+x0*pMem->BytesPerRow;
		     lp3=lp1+y0*pMem->BytesPerRow;
			 lp4=lp1+y2*pMem->BytesPerRow;
			 lp5=lp2+y2*pMem->BytesPerRow;
	         lp6=lp3+y2*pMem->BytesPerRow;
            
			 int n4;
		     for(n3=0;n3<(int)(pMem->Rows);n3++)
			 {
		       for(n2=0;n2<(int)(pMem->BytesPerRow/3);n2++)
			   {
                 n4=n2%(2*pScanner->m_nDPI);
				 if(jiou1[n4]==0)//表示是偶数点

				//A1 扫描仪的拼色程序:B、G、R--> lp3、lp2、lp1 / lp6、lp5、lp4
				//A0 扫描仪的拼色程序:R、G、B--> lp1、lp2、lp3 / lp4、lp5、lp6
                 {
				  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp1+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp2+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp3+3*n2+2);
				 }
				 else
				 {
                  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp4+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp5+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp6+3*n2+2);
				 }
			   }
               lp1=lp1+pMem->BytesPerRow;
               lp2=lp2+pMem->BytesPerRow;
               lp3=lp3+pMem->BytesPerRow;
               lp4=lp4+pMem->BytesPerRow;
               lp5=lp5+pMem->BytesPerRow;
               lp6=lp6+pMem->BytesPerRow;
			 }
               done = TRUE;
               Hour=time1.GetHour();
	           Minute=time1.GetMinute();
	           Second=time1.GetSecond();
               pTesttime->end(Hour,Minute,Second);
               pSetScanner->SCSI_End(huigui); 
 		  }
/////////////////////////////////////////////////////////////////////////////////////
		  if ((bi.biHeight-RowsWritten) ==0 &&count!=0)
		  {
            if(count%2==0)
			   {
                 lp1=lpStart2;
			   }
			   else
			   {
                 lp1=lpStart4;
			   }

             pinj();
			 //拼色并将数据写入到PHOTOSHOP缓冲区中,这是行拼
          	 n2=0;
		     char* pChar;
		     pChar = (char*)pMem->Memory.TheMem;
      
		 	 lp2=lp1+x0*pMem->BytesPerRow;
		     lp3=lp1+y0*pMem->BytesPerRow;
			 lp4=lp1+y2*pMem->BytesPerRow;
			 lp5=lp2+y2*pMem->BytesPerRow;
	         lp6=lp3+y2*pMem->BytesPerRow;
            
			 int n4;
		     for(n3=0;n3<(int)(pMem->Rows);n3++)
			 {
		       for(n2=0;n2<(int)(pMem->BytesPerRow/3);n2++)
			   {
                 n4=n2%(2*pScanner->m_nDPI);
				//A1 扫描仪的拼色程序:B、G、R--> lp3、lp2、lp1 / lp6、lp5、lp4
				//A0 扫描仪的拼色程序:R、G、B--> lp1、lp2、lp3 / lp4、lp5、lp6
				 if(jiou1[n4]==0)//表示是偶数点
                 {
				  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp1+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp2+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp3+3*n2+2);
				 }
				 else
				 {
                  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp4+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp5+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp6+3*n2+2);
				 }
			   }
               lp1=lp1+pMem->BytesPerRow;
               lp2=lp2+pMem->BytesPerRow;
               lp3=lp3+pMem->BytesPerRow;
               lp4=lp4+pMem->BytesPerRow;
               lp5=lp5+pMem->BytesPerRow;
               lp6=lp6+pMem->BytesPerRow;
			 }
             done = TRUE;
             Hour=time1.GetHour();
	         Minute=time1.GetMinute();
	         Second=time1.GetSecond();
             pTesttime->end(Hour,Minute,Second);
             pSetScanner->SCSI_End(huigui);  

		  } 

		 if ((bi.biHeight-RowsWritten)!=0)
		  {
			 if(count%2==0)//否则读下块数据到内存2中
			 {
             //内存1中的一部分数据读入到内存2中
		   	   lpBits2=lpStart2+pMem->Rows*pMem->BytesPerRow;
               lpBits4=lpStart4;
		       memcpy(lpBits4,lpBits2,y1*pMem->BytesPerRow);
		       lpBits4=lpStart4+y1*pMem->BytesPerRow;
		    
               //准备读入内存2中的数据,然后处理内存1中的数据
               if((int)((pMem->Rows)*pMem->BytesPerRow)>nReadInBytes)
			   {
			    n1=((pMem->Rows)*pMem->BytesPerRow)/nReadInBytes;
			    nReadInBytes0=((pMem->Rows)*pMem->BytesPerRow)-n1*nReadInBytes;
			   }
		       else
			   {
			    n1=0;
			    nReadInBytes0=(pMem->Rows)*pMem->BytesPerRow;
			   }

               nReadInBytes1=nReadInBytes/3;
	           nReadInBytes2=nReadInBytes0/3; 

		       downRow=(nReadInBytes*n1)/pMem->BytesPerRow;
		       SCSI_Read1(lpBits,nReadInBytes*n1+nReadInBytes0,nReadInBytes1*n1+nReadInBytes2,downRow+nReadInBytes0/pMem->BytesPerRow,count+1);
             
			   lp1=lpStart2;
			 }
             else //count%2!=0
			 {
               //内存2中的一部分数据读入到内存1中
		   	   lpBits4=lpStart4+pMem->Rows*pMem->BytesPerRow;
               lpBits2=lpStart2;
		       memcpy(lpBits2,lpBits4,y1*pMem->BytesPerRow);
		       lpBits2=lpStart2+y1*pMem->BytesPerRow;
		    
               //准备读入内存2中的数据,然后处理内存1中的数据
                if((int)((pMem->Rows)*pMem->BytesPerRow)>nReadInBytes)
				{
			     n1=((pMem->Rows)*pMem->BytesPerRow)/nReadInBytes;
			     nReadInBytes0=((pMem->Rows)*pMem->BytesPerRow)-n1*nReadInBytes;
				}
		        else
				{
			     n1=0;
			     nReadInBytes0=(pMem->Rows)*pMem->BytesPerRow;
				}
 
                nReadInBytes1=nReadInBytes/3;
	            nReadInBytes2=nReadInBytes0/3;
				
		        downRow=(nReadInBytes*n1)/pMem->BytesPerRow;
		        SCSI_Read1(lpBits,nReadInBytes*n1+nReadInBytes0,nReadInBytes1*n1+nReadInBytes2,downRow+nReadInBytes0/pMem->BytesPerRow,count+1);
             	lp1=lpStart4;
			 }//end else
		    //行拼之前,首先要进行奇偶拼,使得在一行,处理内存1中的数据
			 pinj();
			 //拼色并将数据写入到PHOTOSHOP缓冲区中,这是行拼
          
	         n2=0;
		     char* pChar;
		     pChar = (char*)pMem->Memory.TheMem;
      
		 	 lp2=lp1+x0*pMem->BytesPerRow;
		     lp3=lp1+y0*pMem->BytesPerRow;
			 lp4=lp1+y2*pMem->BytesPerRow;
			 lp5=lp2+y2*pMem->BytesPerRow;
	         lp6=lp3+y2*pMem->BytesPerRow;
            
			 int n4;
		     for(n3=0;n3<(int)(pMem->Rows);n3++)
			 {
		       for(n2=0;n2<(int)(pMem->BytesPerRow/3);n2++)
			   {
                 n4=n2%(2*pScanner->m_nDPI);
				//A1 扫描仪的拼色程序:B、G、R--> lp3、lp2、lp1 / lp6、lp5、lp4
				//A0 扫描仪的拼色程序:R、G、B--> lp1、lp2、lp3 / lp4、lp5、lp6
				 if(jiou1[n4]==0)//表示是偶数点
                 {
				  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp1+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp2+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp3+3*n2+2);
				 }
				 else
				 {
                  *(pChar+n3*pMem->BytesPerRow+3*n2)=*(unsigned char*)(lp4+3*n2);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+1)=*(unsigned char*)(lp5+3*n2+1);
			      *(pChar+n3*pMem->BytesPerRow+3*n2+2)=*(unsigned char*)(lp6+3*n2+2);
				 }
			   }
               lp1=lp1+pMem->BytesPerRow;
               lp2=lp2+pMem->B

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -