如何提取游戏中的文字

如何提取游戏中的文字,第1张

用Office 2003提取中的文字
第一步 我们需要安装“Microsoft Office Document Imaging”的组件,点“开始→程序”,在 “Microsoft Office 工具” 里点“ Microsoft Office Document Imaging” 即可安装运行。
第二步 打开带有文字的或电子书籍等,找到你希望提取的页面,按下键盘上的打印屏幕键(PrintScreen)进行屏幕取图。
第三步 打开Microsoft Office Word 2003 ,将刚才的屏幕截图粘贴进去;点击“文件”菜单中的“打印”,在安装Microsoft Office Document Imaging组件后,系统会自动安装一个名为“Microsoft Office Document Imaging Writer”的打印机。
“Microsoft Office Document Imaging Writer”打印机,其他选项无须额外设置,点击“确定”按钮后,设定好文件输出的路径及文件名(缺省使用源文件名),然后很快就可以自动生成一个MDI格式的文档了。
打开刚才保存的MDI类型文件(如图3所示),根据你的需要用鼠标选择文字内容(被选中的内容在红色的框内),然后单击鼠标右键,在d出的快捷菜单中选择“将文本发送到Word”,即可将内容自动转换为一个新的Word文档,然后你就可以在Word文档中随心所欲地进行编辑这段文字了。
提示:如果你不想将转换的内容输入到一个新的Word 文档中,而是希望粘贴到一个已经打开的Word 文档,只需在上面的 *** 作中点击右键菜单的“复制”,然后再到指定文档中执行粘贴即可。
offiice2003 确实有这个功能!
自带了Document Imaging 安装office的时候选上
默认是不安装的!
还有很多OCR软件
我使用Document Imaging的时候感觉非常不错! 推荐一下
如果 公式 字母 中文 混排
任何软件都识别不全的!
用OCR就可以了.
比如Office 2003中也提供了文字识别服务,结合那个Image writer可以很方便将PDF转成WORD。
第一种方法:用SnagIt工具进行文字提取。
首先使用SnagIt的文字捕捉功能将文字提取出来。SnagIt当前版本为702,大小为8903KB,下载地址可以在>using System;
using SystemCollectionsGeneric;
using SystemText;
namespace SnhjCmsCommon
{
/// <summary>
/// 处理类
/// </summary>
public static class PictureUtil
{
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="imgPath">原路径</param>
/// <param name="breviaryPath">缩略图路径</param>
/// <param name="width">缩略图宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">生成方式</param>
public static void MakeBreviaryPhoto(string imgPath, string breviaryPath, int width, int height, string mode)
{
SystemDrawingImage image = SystemDrawingImageFromFile(imgPath);
int x = 0, y = 0;
int w = imageWidth;
int h = imageHeight;
switch (mode)
{
case "HW"://指定高度和宽度缩放(会变形)
break;
case "W"://指定宽度缩放,高度按比例。
height = h width / w;
break;
case "H"://指定高度缩放,宽度按比例。
width = w height / h;
break;
case "Cut"://指定高度和宽度裁剪。
if ((double)w / (double)h > (double)width / (double)height)
{
w = h width / height;
x = (imageWidth - w) / 2;
}
else
{
h = w height / width;
y = (imageHeight - h) / 2;
}
break;
default:
break;
}
//创建一个bmp
SystemDrawingImage bmpImg = new SystemDrawingBitmap(width, height);
//新建一个画板
SystemDrawingGraphics g = SystemDrawingGraphicsFromImage(bmpImg);
//设置高质量插值法
gInterpolationMode = SystemDrawingDrawing2DInterpolationModeHigh;
//设置高质量,低速度呈现平滑程度
gSmoothingMode = SystemDrawingDrawing2DSmoothingModeHighQuality;
//清空画布并以透明背景色填充
gClear(SystemDrawingColorTransparent);
//在指定位置并且按指定大小绘制原的指定部分
gDrawImage(image, new SystemDrawingRectangle(0,0,width,height), new SystemDrawingRectangle(x,y,w,h), SystemDrawingGraphicsUnitPixel);
try
{
//以jpg格式保存缩略图
bmpImgSave(breviaryPath, SystemDrawingImagingImageFormatJpeg);
}
catch (Exception e)
{
throw e;
}
finally
{
imageDispose();
bmpImgDispose();
gDispose();
}
}
/// <summary>
/// 加水印
/// </summary>
/// <param name="filename">文件名</param>
/// <param name="watermarkFilename">水印文件名</param>
/// <param name="watermarkStatus">水印位置:0=不使用 1=左上 2=中上 3=右上 4=左中 9=右下</param>
/// <param name="quality">是否是高质量 取值范围0--100</param>
/// <param name="watermarkTransparency">水印透明度 取值范围1--10 (10为不透明)</param>
public static void AddImageSignPic(string Path, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
{
SystemDrawingImage img = SystemDrawingImageFromFile(Path);
SystemDrawingGraphics g = SystemDrawingGraphicsFromImage(img);
//设置高质量插值法
//gInterpolationMode = SystemDrawingDrawing2DInterpolationModeHigh;
//设置高质量,低速度呈现平滑程度
//gSmoothingMode = SystemDrawingDrawing2DSmoothingModeHighQuality;
SystemDrawingImage watermark = new SystemDrawingBitmap(watermarkFilename);
if (watermarkHeight >= imgHeight || watermarkWidth >= imgWidth)
{
return;
}
SystemDrawingImagingImageAttributes imageAttributes = new SystemDrawingImagingImageAttributes();
SystemDrawingImagingColorMap colorMap = new SystemDrawingImagingColorMap();
colorMapOldColor = SystemDrawingColorFromArgb(255, 0, 255, 0);
colorMapNewColor = SystemDrawingColorFromArgb(0, 0, 0, 0);
SystemDrawingImagingColorMap[] remapTable = { colorMap };
imageAttributesSetRemapTable(remapTable, SystemDrawingImagingColorAdjustTypeBitmap);
float transparency = 05F;
if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
{
transparency = (watermarkTransparency / 100F);
}
float[][] colorMatrixElements = {
new float[] {10f, 00f, 00f, 00f, 00f},
new float[] {00f, 10f, 00f, 00f, 00f},
new float[] {00f, 00f, 10f, 00f, 00f},
new float[] {00f, 00f, 00f, transparency, 00f},
new float[] {00f, 00f, 00f, 00f, 10f}
};
SystemDrawingImagingColorMatrix colorMatrix = new SystemDrawingImagingColorMatrix(colorMatrixElements);
imageAttributesSetColorMatrix(colorMatrix, SystemDrawingImagingColorMatrixFlagDefault, SystemDrawingImagingColorAdjustTypeBitmap);
int xpos = 0;
int ypos = 0;
switch (watermarkStatus)
{
case 1:
xpos = (int)(imgWidth (float)01);
ypos = (int)(imgHeight (float)01);
break;
case 2:
xpos = (int)((imgWidth (float)50) - (watermarkWidth / 2));
ypos = (int)(imgHeight (float)01);
break;
case 3:
xpos = (int)((imgWidth (float)99) - (watermarkWidth));
ypos = (int)(imgHeight (float)01);
break;
case 4:
xpos = (int)(imgWidth (float)01);
ypos = (int)((imgHeight (float)50) - (watermarkHeight / 2));
break;
case 5:
xpos = (int)((imgWidth (float)50) - (watermarkWidth / 2));
ypos = (int)((imgHeight (float)50) - (watermarkHeight / 2));
break;
case 6:
xpos = (int)((imgWidth (float)99) - (watermarkWidth));
ypos = (int)((imgHeight (float)50) - (watermarkHeight / 2));
break;
case 7:
xpos = (int)(imgWidth (float)01);
ypos = (int)((imgHeight (float)99) - watermarkHeight);
break;
case 8:
xpos = (int)((imgWidth (float)50) - (watermarkWidth / 2));
ypos = (int)((imgHeight (float)99) - watermarkHeight);
break;
case 9:
xpos = (int)((imgWidth (float)99) - (watermarkWidth));
ypos = (int)((imgHeight (float)99) - watermarkHeight);
break;
}
gDrawImage(watermark, new SystemDrawingRectangle(xpos, ypos, watermarkWidth, watermarkHeight), 0, 0, watermarkWidth, watermarkHeight, SystemDrawingGraphicsUnitPixel, imageAttributes);
SystemDrawingImagingImageCodecInfo[] codecs = SystemDrawingImagingImageCodecInfoGetImageEncoders();
SystemDrawingImagingImageCodecInfo ici = null;
foreach (SystemDrawingImagingImageCodecInfo codec in codecs)
{
if (codecMimeTypeIndexOf("jpeg") > -1)
{
ici = codec;
}
}
SystemDrawingImagingEncoderParameters encoderParams = new SystemDrawingImagingEncoderParameters();
long[] qualityParam = new long[1];
if (quality < 0 || quality > 100)
{
quality = 80;
}
qualityParam[0] = quality;
SystemDrawingImagingEncoderParameter encoderParam = new SystemDrawingImagingEncoderParameter(SystemDrawingImagingEncoderQuality, qualityParam);
encoderParamsParam[0] = encoderParam;
if (ici != null)
{
imgSave(filename, ici, encoderParams);
}
else
{
imgSave(filename);
}
gDispose();
imgDispose();
watermarkDispose();
imageAttributesDispose();
}
/// <summary>
/// 在上生成水印
/// </summary>
/// <param name="Path">原服务器路径</param>
/// <param name="Path_syp">生成的带水印的路径</param>
/// <param name="Path_sypf">水印路径</param>
public static void AddWaterPic(string Path, string Path_syp, string Path_sypf)
{
SystemDrawingImage image = SystemDrawingImageFromFile(Path);
SystemDrawingImage copyImage = SystemDrawingImageFromFile(Path_sypf);
SystemDrawingGraphics g = SystemDrawingGraphicsFromImage(image);
gDrawImage(copyImage, new SystemDrawingRectangle(imageWidth - copyImageWidth, imageHeight - copyImageHeight, copyImageWidth, copyImageHeight), 0, 0, copyImageWidth, copyImageHeight, SystemDrawingGraphicsUnitPixel);
gDispose();
imageSave(Path_syp);
imageDispose();
}
}
}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/13469240.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-13
下一篇 2023-08-13

发表评论

登录后才能评论

评论列表(0条)

保存