Click here to Skip to main content
16,013,581 members
Home / Discussions / C#
   

C#

 
Questionthe blinking cursor Pin
melanieab13-Jan-06 11:07
melanieab13-Jan-06 11:07 
AnswerRe: the blinking cursor Pin
Koushik Biswas13-Jan-06 12:38
Koushik Biswas13-Jan-06 12:38 
GeneralRe: the blinking cursor Pin
Dave Kreskowiak13-Jan-06 14:35
mveDave Kreskowiak13-Jan-06 14:35 
AnswerRe: the blinking cursor Pin
Dave Kreskowiak13-Jan-06 14:36
mveDave Kreskowiak13-Jan-06 14:36 
AnswerRe: the blinking cursor Pin
DigitalKing13-Jan-06 15:00
DigitalKing13-Jan-06 15:00 
GeneralRe: the blinking cursor Pin
Dave Kreskowiak13-Jan-06 15:07
mveDave Kreskowiak13-Jan-06 15:07 
GeneralRe: the blinking cursor Pin
melanieab16-Jan-06 4:30
melanieab16-Jan-06 4:30 
QuestionHow can I concaternate images together in C# Pin
jung197513-Jan-06 10:52
jung197513-Jan-06 10:52 
I would like to make the images concaternated and display it.
For example, I would like to put COUP images together and display them together. I can display the first image but am not able to display the second images.
How can I concaternate two images and display them together in c#?


Here is my tables:

Data table
Transactionid documenttype frontimage offset frontimage size
1934318415 CHECK 1 11264
1934318415 COUP 18433 27648
1934318415 COUP 57345 39936

The front/rear offset tell you where the image data in image table begins and the front/rear length tell you how many bytes from the offset to extract to get the image out of the Image table..

Image table
Transaction ID, Image
1934318415 <binary>


Here is the code:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Data.SqlClient;
using System.IO;
using System.Drawing.Imaging;
using System.Collections.Generic;

public partial class GetImage : System.Web.UI.Page
{

protected override void OnLoad(EventArgs e)
{

base.OnLoad(e);
_GetMultipleImages();
}


public void _GetMultipleImages ()
{

string TransactionId;
string sql;
byte[] imageBytes = null;
TransactionId = (string)this.Request.QueryString["TransactionId"];
if (TransactionId == null) return;

TransactionId = int.Parse(TransactionId).ToString();
sql = "Select Image from Image where TransactionId=" + TransactionId;
ConnectionStringSettings cnSetting =
ConfigurationManager.ConnectionStrings["AppConnectionString6"];
using (SqlConnection cn = new SqlConnection(cnSetting.ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(sql, cn))
{
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
dr.Read();
imageBytes = (byte[])dr["Image"];
}
}
}
}

if (imageBytes == null || imageBytes.Length == 0) return;
List<byte> imgBytes = new List<byte>();

using (SqlConnection cn = new SqlConnection(cnSetting.ConnectionString))
{
sql= "select FrontImageOffset, FrontImageSize,Rearimageoffset, RearImageSize from Image a join Data b on a.transactionid = b.transactionid where documenttype = 'CHECK' and b.TransactionId=" + TransactionId;
using (SqlCommand cmd = new SqlCommand(sql, cn))
{
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
if (dr.Read())
{

long imagebytesLen = imageBytes.Length;
MemoryStream ImageStream = new MemoryStream(imageBytes);

do
{
int frontoffset = Convert.ToInt32(dr["FrontImageOffset"]) - 1;
int frontlength = Convert.ToInt32(dr["FrontImageSize"]);
int rearlength = Convert.ToInt32(dr["RearImageSize"]);

if (imagebytesLen >= (frontlength + rearlength))
{

byte[] newimage = new byte[frontlength + rearlength];
ImageStream.Seek(frontoffset, SeekOrigin.Begin);
ImageStream.Read(newimage, 0, newimage.Length);

imgBytes.AddRange(newimage);
}

} while (dr.NextResult());

ImageStream.Close();
}
}

dr.Close();
}
}
}

if (imgBytes.Count > 0)
{
Bitmap bmp = new Bitmap(new MemoryStream(imgBytes.ToArray()));
Response.ContentType = "Image/gif";
bmp.Save(Response.OutputStream, ImageFormat.Gif);
Response.End();
}
}
}
QuestionIs C# right for me? Pin
tansey413-Jan-06 9:45
tansey413-Jan-06 9:45 
AnswerRe: Is C# right for me? Pin
RizwanSharp13-Jan-06 9:56
RizwanSharp13-Jan-06 9:56 
GeneralRe: Is C# right for me? Pin
Colin Angus Mackay13-Jan-06 11:09
Colin Angus Mackay13-Jan-06 11:09 
GeneralRe: Is C# right for me? Pin
RizwanSharp13-Jan-06 16:47
RizwanSharp13-Jan-06 16:47 
AnswerRe: Is C# right for me? Pin
Dan Neely13-Jan-06 10:12
Dan Neely13-Jan-06 10:12 
GeneralRe: Is C# right for me? Pin
tansey413-Jan-06 13:31
tansey413-Jan-06 13:31 
QuestionSerialization and Encryption Problem (Urget and most important) Pin
RizwanSharp13-Jan-06 9:32
RizwanSharp13-Jan-06 9:32 
AnswerRe: Serialization and Encryption Problem (Urget and most important) Pin
Robert Rohde14-Jan-06 21:49
Robert Rohde14-Jan-06 21:49 
GeneralRe: Serialization and Encryption Problem (Urget and most important) Pin
RizwanSharp15-Jan-06 2:59
RizwanSharp15-Jan-06 2:59 
GeneralRe: Serialization and Encryption Problem (Urget and most important) Pin
Dan Neely16-Jan-06 2:19
Dan Neely16-Jan-06 2:19 
Questioncustom control Pin
mihai_152913-Jan-06 9:03
mihai_152913-Jan-06 9:03 
AnswerRe: custom control Pin
Sasuko13-Jan-06 13:57
Sasuko13-Jan-06 13:57 
GeneralRe: custom control Pin
mihai_152913-Jan-06 20:46
mihai_152913-Jan-06 20:46 
QuestionBasic question. Pin
Taurian11013-Jan-06 8:34
Taurian11013-Jan-06 8:34 
AnswerRe: Basic question. Pin
User 665813-Jan-06 8:39
User 665813-Jan-06 8:39 
AnswerRe: Basic question. Pin
Dave Kreskowiak13-Jan-06 8:54
mveDave Kreskowiak13-Jan-06 8:54 
GeneralRe: Basic question. Pin
User 665813-Jan-06 8:58
User 665813-Jan-06 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.