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

📄 uo_photo.sru

📁 pb开发的摄像头 控制源代码
💻 SRU
字号:
$PBExportHeader$uo_photo.sru
$PBExportComments$用于: 获取/显示 相片
forward
global type uo_photo from picture
end type
end forward

global type uo_photo from picture
integer width = 553
integer height = 556
boolean focusrectangle = false
end type
global uo_photo uo_photo

type variables

end variables

forward prototypes
public function integer of_getphoto (string as_fullname, ref blob abb_photo)
public function integer of_setphoto (readonly blob abb_photo)
public subroutine of_clearphoto ()
end prototypes

public function integer of_getphoto (string as_fullname, ref blob abb_photo);/**************************************************
*
* Function: Get photo indicated by as_fullName and return it to abb_photo
* Parameter: 	as_fullName - in,  photo's full path like 'c:\photo.bmp'
*					abb_photo - out, stored the photo
* Return VAlue:	Null - if any parameter is null
*						-1   - an error occur
*						 1   - success  
*
***************************************************/
long		rtn
long		ll_fLen		// photo size
int		li_hFile		// handle to the photo
int		li_loops
int		i
blob		lbb_Photo	
blob		lbb_buffer

//
// Validate the function parameter
//
if IsNull(as_fullName) or IsNull(abb_photo) then
	SetNull(rtn)
	Return(rtn)
end if

if not FileExists(as_fullName) then
	MessageBox('错误', '图片文件不存在!')
	Return -1
end if

//
// get photo from file 
//
li_hFile = FileOpen(as_fullName, StreamMode!, Read!, LockWrite!)
if li_hFile = -1 or IsNull(li_hFile) then
	MessageBox('错误', '获取文件句柄失败!')
	Return -1
end if

ll_fLen = FileLength(as_fullName)
if ll_fLen = -1 or IsNull(ll_fLen) then
	MessageBox('错误', '获取文件大小失败!')
	Return -1
end if

if ll_fLen > 32765 then
	if Mod(ll_fLen, 32765) = 0 then
		li_loops = ll_fLen / 32765
	else
		li_loops = (ll_fLen / 32765) + 1
	end if
else
	li_loops = 1
end if

for i = 1 to li_loops step 1
	FileRead(li_hFile, lbb_buffer)
	lbb_photo += lbb_buffer
next

FileClose(li_hFile)

//
// Success
//
abb_photo = lbb_photo

return 1
end function

public function integer of_setphoto (readonly blob abb_photo);/*****************************************************
*
* Function: Display photo stored in abb_photo
* Parameter: abb_photo - in, blob stored the photo
* Return value: -1 - error occur
*					  1 - Success
*
*****************************************************/
int	rtn

if IsNull(abb_photo) then
	SetNull(rtn)
	Return rtn
end if

rtn = This.SetPicture(abb_photo)
if rtn = 1 then
	Return 1			// Success
else
	MessageBox('错误', '显示相片失败!')
	Return -1
end if
end function

public subroutine of_clearphoto ();/*******************************
*
* Clear the picture displayed in uo_photo
*
*******************************/
This.pictureName = '$NoPhoto$'
end subroutine

on uo_photo.create
end on

on uo_photo.destroy
end on

⌨️ 快捷键说明

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