473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamic images from byte array

Hi there,
Hope someone can help. I've had a look around on the web and found
some useful info but not getting this to work... seen lots of
different variations

PROBLEM:
========
I have a pop-up window in which to display a logo. These logos are
stored in SQL Server 2000 as <image> objects.

I'm bringing them back and converting into a byte array. All ok so
far, byte array is populated.

In the page in which I wish to show the logo, I have written:

<asp:Image Runat="server" ID="imgLogo" BorderWidth="0" />

In the code behind I have pointed the ImageUrl to another page that
contains no code whatsoever apart from the reference to its code
behind. I have also appended a couple of values to the querystring.
I've done this as I understand the need to output the image separately
from the HTML that is being output on the other page.

Once I have called the method to bring back the logo byte array, I
then use the following:

Response.Buffer = true;
Response.ContentType = "image/gif";
Response.BinaryWrite(logo); // 'logo' is a byte[]

WHAT HAPPENS:
=============
Nothing. Thats the problem - the image is not being output to screen.
I look at the source and see my image server control being rendered as
a regular image with a src value pointing to the page that retrieves
the image byte array.

Now, I don't want to save anything onto the webserver, I'd just like
to output directly from the byte array.

Any ideas on what I'm doing wrong?
Any help would be most appreciated!
Regards,
Andrew
Nov 18 '05 #1
2 2370
Andrew,

I have very similar page that works just fine, In this page I get an image
as System.Data.SqlTypes.SqlBinary and then output it with the following
lines:
Response.ContentType = "image/gif";
Response.OutputStream.Write (image.Value, 0, image.Length);
It is the same what you are doing. Furthermore, I replaced the second line
with Response.BinaryWrite (image.Value); and it also worked.

I think you are on the right track and the code is OK. May be you are not
reading into your logo array properly or the images are of different format?

Eliyahu

"Knoxy" <an*********@arsenalnews.co.uk> wrote in message
news:23**************************@posting.google.c om...
Hi there,
Hope someone can help. I've had a look around on the web and found
some useful info but not getting this to work... seen lots of
different variations

PROBLEM:
========
I have a pop-up window in which to display a logo. These logos are
stored in SQL Server 2000 as <image> objects.

I'm bringing them back and converting into a byte array. All ok so
far, byte array is populated.

In the page in which I wish to show the logo, I have written:

<asp:Image Runat="server" ID="imgLogo" BorderWidth="0" />

In the code behind I have pointed the ImageUrl to another page that
contains no code whatsoever apart from the reference to its code
behind. I have also appended a couple of values to the querystring.
I've done this as I understand the need to output the image separately
from the HTML that is being output on the other page.

Once I have called the method to bring back the logo byte array, I
then use the following:

Response.Buffer = true;
Response.ContentType = "image/gif";
Response.BinaryWrite(logo); // 'logo' is a byte[]

WHAT HAPPENS:
=============
Nothing. Thats the problem - the image is not being output to screen.
I look at the source and see my image server control being rendered as
a regular image with a src value pointing to the page that retrieves
the image byte array.

Now, I don't want to save anything onto the webserver, I'd just like
to output directly from the byte array.

Any ideas on what I'm doing wrong?
Any help would be most appreciated!
Regards,
Andrew

Nov 18 '05 #2
Ahem - I have to admit I'd figured this out about half an hour after
my post... I was looking in the wrong place for the solution to my
problem.

On my method that saved the image to the database I'd declared the
image parameter like so:

comm.Parameters.Add("@logo", SqlDbType.Image, 16).Value =
oBranding.Logo;

Therefore I was only saving the first 16 bytes in the database and
thats why the image wasnt coming out... ah, the shame...
Cheers for your reply though, most appreciated!
Andrew
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a...
8
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
4
by: Mahmoud Mousa | last post by:
Hi... Some how I'm facing trouble Saving A Bitmap(I Dynamiclly creat in my Page) Co's Every Time to Started to save the Image.. The Only thing that Appears in my Page is the Image Alone And If I...
3
by: | last post by:
Hi, I have a SQL Server database table where one of the columns is of type Image. The problem occurs when I try to retrieve images from the table. I'm using the following C# code: ...
9
by: charliewest | last post by:
Hello - I have images saved in my SQL SERVER 2000 database. Using ASP.NET (C#) is there any way to temporarily save an image to a session object, and after running some other operations, later...
8
by: Bob | last post by:
I'm looking for an example of how to extract images from an Access 97 blob into an asp datagrid. Anybody have examples?
3
by: Alan | last post by:
Hi, I'm converting a database application from Access 97 to C#/SQL Server. Old database contains some images in OLE fields. I've figured out that there's OLE header preceeding actual image data...
3
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I'm having the wierdest problem. I'm trying to save images into a SQL 2005 database. the field is just called "IMAGES" and hte data type is "image". here is my code to save //following code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.