-
-
Save defaultlocale/1877bad08ee71f5b2a97b3eaf026ba5f to your computer and use it in GitHub Desktop.
Oracle TIFF image query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
using System.IO; | |
using Oracle.ManagedDataAccess.Client; | |
namespace OracleTiffImage | |
{ | |
static class Program | |
{ | |
private const string CONNECTION_STRING = "data source=DB;user id=USER;password=\"password\";pooling=false"; | |
static void Main() | |
{ | |
using (var cn = new OracleConnection(CONNECTION_STRING)) | |
{ | |
var imgCmd = new OracleCommand("select SIGNATURE from image_table", cn) | |
{ | |
InitialLONGFetchSize = -1 | |
}; | |
cn.Open(); | |
var reader = imgCmd.ExecuteReader(); | |
if (reader.Read()) | |
{ | |
var imgBinary = reader.GetOracleBinary(0); | |
var imgBytes = imgBinary.Value; | |
var stream = new MemoryStream(); | |
stream.Write(imgBytes, 0, imgBytes.Length); | |
var bm = new Bitmap(stream); | |
bm.Save("d:\\image.tif", System.Drawing.Imaging.ImageFormat.Tiff); | |
} | |
reader.Close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment