using System;
using System.IO;
using System.Drawing;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks; namespace DBImg
{
public class ImageFile
{
public byte[] GetPictureData(string filePath)
{
if (!File.Exists(filePath))
return null; byte[] byteData = null;
using (FileStream fs = new FileStream(filePath, FileMode.Open,FileAccess.Read))
{
byteData = new byte[fs.Length];
fs.Read(byteData, 0, byteData.Length);
fs.Close();
}
return byteData;
} public Image ReturnPhoto(byte[] streamByte)
{
MemoryStream ms = new MemoryStream(streamByte);
Image img = Image.FromStream(ms); return img;
} public bool SavePhoto(byte[] streamByte, string outputFile)
{
if (File.Exists(outputFile))
{
File.Delete(outputFile);
} bool saveCmplete = false;
using (FileStream fs = new FileStream(outputFile, FileMode.CreateNew))
{
fs.Write(streamByte, 0, streamByte.Length);
fs.Close();
saveCmplete = true;
} return saveCmplete;
}
}
}

DBImg: 图片文件-二进制文件的转换的更多相关文章

  1. C#实现图片文件到数据流再到图片文件的转换 --转

    /----引入必要的命名空间 using System.IO; using System.Drawing.Imaging; //----代码部分----// private byte[] photo; ...

  2. html5中将图片的绝对路径转换成文件对象

    html5中将图片的绝对路径转换成文件对象 将图片的绝对路径转换成base64编码,请看这篇文章 我们先来理解基本知识点: 1. 理解HTML5中的FileList对象与file对象. 在HTML5中 ...

  3. js 将图片文件转换成base64

      1.情景展示 在JavaScript中,如何使用图片文件转换成base64? 2.解决方案 /** * 网络图像文件转Base64 * @param img dom对象 */ function g ...

  4. js如何将选中图片文件转换成Base64字符串?

    如何将input type="file"选中的文件转换成Base64的字符串呢? 1.首先了解一下为什么要把图片文件转换成Base64的字符串 在常规的web开发过程中,大部分上传 ...

  5. winform利用itextsharp.dll实现图片文件转换PDF格式文件

    1.利用itextsharp.dll实现单个图片文件转换为PDF格式文件, 可以使用以下类: void ConvertJPG2PDF(string jpgfile, string pdf) { var ...

  6. C#实现图片文件到数据流再到图片文件的转换

    //----引入必要的命名空间using System.IO;using System.Drawing.Imaging; //----代码部分----// private byte[] photo;/ ...

  7. WPF中实现图片文件转换成Visual对象,Viewport3D对象转换成图片

    原文:WPF中实现图片文件转换成Visual对象,Viewport3D对象转换成图片 1.图片文件转换成Visual对象 private Visual CreateVisual(string imag ...

  8. C#实现图片文件到数据流,再到图片文件的转换

    //----引入必要的命名空间 using System.IO; using System.Drawing.Imaging; //----代码部分----// private byte[] photo ...

  9. C# 图片文件与字符串之间的转换

    1.将图片文件转化为字符串类型 2.将字符串类型的图片数据转换为本地图片保存

随机推荐

  1. 给Eclipse中hibernate.cfg.xml配置文件加提示

    在hibernate框架需要的jar包中找到hibernate3.jar,并用压缩软件打开,如图: 2 选择org文件夹--打开下一级文件夹 3 点击类型,方便找到dtd文件,下拉查看dtd文件,有两 ...

  2. 算法——js(Fibonacci数列)

    斐波那契数列(Fibonacci sequence),又称黄金分割数列,因数学家列昂纳多·斐波那契(Leonardoda Fibonacci[1]  )以兔子繁殖为例子而引入,故又称为“兔子数列”,指 ...

  3. lucene底层数据结构——底层filter bitset原理,时间序列数据压缩将同一时间数据压缩为一行

    如何联合索引查询? 所以给定查询过滤条件 age=18 的过程就是先从term index找到18在term dictionary的大概位置,然后再从term dictionary里精确地找到18这个 ...

  4. [整理]Svn常见问题汇总。

    1.’.’ is not a working copy.Can’t open file‘.svn/entries’: 系统找不到指定的路径. 解答:原因是输入的访问路径不正确,如svn://192.1 ...

  5. MySQL 建库、建用户及建表事项

    1,MySQL建库语句比较简单,一句话: create database tppamltest3 2,创建用户及授权: insert into mysql.user(Host,User,Passwor ...

  6. HBase HMaster Architecture - HBase Master架构

    HBase architecture follows the traditional master slave model where you have a master which takes de ...

  7. 如何在Hadoop的MapReduce程序中处理JSON文件

    简介: 最近在写MapReduce程序处理日志时,需要解析JSON配置文件,简化Java程序和处理逻辑.但是Hadoop本身似乎没有内置对JSON文件的解析功能,我们不得不求助于第三方JSON工具包. ...

  8. How to Run a .Jar Java File

    .jar files are used for archiving, archive unpacking. One of the essential features of jar file is l ...

  9. [Jquery]导航菜单效果-纵向

    $( document ).ready( function(e){ var $catCont = $( ".cat-cont" );    //二级菜单div    var $ca ...

  10. bzoj 2286: [Sdoi2011消耗战

    #include<cstdio> #include<iostream> #define M 1000009 #define N 250009 #define ll long l ...