从原有的15位身份证号转换成新的18位

 create or replace function GetNewID(p_OldID varchar2) return varchar2 is
-- Author : XJG
-- Created : 2003-11-03 18:38:56
-- Purpose : 从原有的15位身份证号转换成新的18位
type TIArray is table of integer;
type TCArray is table of char(1);
Result varchar2(18);
W TIArray;
A TCArray;
S integer;
begin
if Length(p_OldID) <> 15 then
raise_application_error(-20999, '不是旧15位身份证号');
end if;
W := TIArray(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
A := TCArray('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
Result := SubStr(p_OldID, 1, 6) || '19' || SubStr(p_OldID, 7, 9);

S := 0;
begin
for i in 1 .. 17 loop
S := S + to_number(SubStr(Result, i, 1)) * W(i);
end loop;
exception
when others then
return '';
end;
S := S mod 11;
Result := Result || A(s + 1);

return(Result);
end GetNewID;

 

好的,您可以使用C#的图像处理库来实现这个功能。以下是一个简单的代码示例: ```csharp using System.Drawing; public static void CropIDCard(string originalImagePath, string croppedImagePath) { // 身份证图片的宽度和高度 int idCardWidth = 850; int idCardHeight = 540; // 加载原始图片 Image originalImage = Image.FromFile(originalImagePath); // 创建一个身份证大小的图片 Image croppedImage = new Bitmap(idCardWidth, idCardHeight); // 创建一个 Graphics 对象,用于在图片上绘制原始图片的一部分 Graphics graphics = Graphics.FromImage(croppedImage); // 定义一个矩形,表示要截取的图片区域 Rectangle sourceRectangle = new Rectangle(0, 0, idCardWidth, idCardHeight); // 定义一个矩形,表示要绘制的目标区域 Rectangle destinationRectangle = new Rectangle(0, 0, idCardWidth, idCardHeight); // 绘制原始图片的一部分到图片上 graphics.DrawImage(originalImage, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel); // 保存图片 croppedImage.Save(croppedImagePath, ImageFormat.Jpeg); // 释放资源 graphics.Dispose(); croppedImage.Dispose(); originalImage.Dispose(); } ``` 在这个示例中,`originalImagePath` 参数是原始图片的路径,`croppedImagePath` 参数是要保存的图片的路径。`idCardWidth` 和 `idCardHeight` 变量定义了身份证图片应该具有的宽度和高度。您可以根据需要修改这些变量的值。 您可以调用 `CropIDCard` 方法来截取图片。例如: ```csharp string originalImagePath = "path/to/original/image.jpg"; string croppedImagePath = "path/to/cropped/image.jpg"; CropIDCard(originalImagePath, croppedImagePath); ``` 这个方法会读取原始图片,截取出身份证图片的部分,并将结果保存到图片中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值