473,406 Members | 2,816 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,406 software developers and data experts.

ASP.net Ques: Image Retrieval

Hi, I am pretty new to ASP.net

I want to do the following but I have been unable to find good info/ or
sample code on it; please help;

- retrieve a gif/jpeg image using ASP.net from another site

- using ASP.net (Visual Basic.net or C#) code I want to edit the image by
superimposing a smaller image on the lower right hand corner

- then display the image to the user

- if possible, store the image to MySQL server

Thank you in advance. and please be as detail as you like.

Joe.

Nov 17 '05 #1
2 1291
Hi,

Maybe you can use this sample that I once made how you can do it. This uses
images in a database, you can as well choise for using paths. Where in my
opinion this one is better for securing your images.

However, when you store your paths in the database, the images can come from
everywhere. (That is a different and easier solution by the way)

\\\For the database the standard Northwind sample database.
\\\It needs 2 forms with a listbox, a picturebox and a label on form1
\\\webform1
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim conn As New SqlClient.SqlConnection _
("Server=(Local); DataBase=Northwind;" & _
"Integrated Security=SSPI")
Dim da As New SqlClient.SqlDataAdapter _
("SELECT FirstName, EmployeeID FROM Employees", conn)
Dim ds As New DataSet
Me.Image1.Visible = False
ListBox1.AutoPostBack = True
Try
da.Fill(ds)
ListBox1.DataSource = ds.Tables(0)
ListBox1.DataTextField = "FirstName"
ListBox1.DataValueField = "EmployeeID"
ListBox1.DataBind()
Catch sqlExc As SqlClient.SqlException
Me.Label1.Text = sqlExc.ToString
Catch exc As Exception
Me.Label1.Text = exc.ToString
End Try
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles ListBox1.SelectedIndexChanged
Session.Item("img") = ListBox1.SelectedItem.Value
Image1.Visible = True
Image1.ImageUrl = "http://localhost/TestWebImage/WebForm2.aspx"
'This is the location of the aspx files
End Sub
///
\\\webform2 watch that the Memstream, which is for Northwind
'the normal code is as well in it.
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New SqlClient.SqlConnection("Server=(Local);" & _
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr As String = _
String.Format("SELECT Photo FROM Employees WHERE (EmployeeID =
{0})", _
CInt(Session.Item("img")))
Dim cmd As New SqlClient.SqlCommand(sqlstr, conn)
conn.Open()
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
rdr.Read()
Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
'Dim ms1 As New System.IO.MemoryStream(arrImage)
'The one above is for normal purpose, however Northwint has a
strange format
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
Dim ms1 As New System.IO.MemoryStream(arrImage, 78,
arrImage.Length - 78)
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
Dim origimage As System.drawing.Image =
System.Drawing.Image.FromStream(ms1)
Dim PThumbnail As System.drawing.Image
PThumbnail = origimage.GetThumbnailImage(100, 100, Nothing, New
IntPtr)
Dim ms2 As New System.IO.MemoryStream
PThumbnail.Save(ms2, Imaging.ImageFormat.Bmp)
arrImage = ms2.GetBuffer
Response.BinaryWrite(arrImage)
rdr.Close()
conn.Close()
End Sub
///

I hope this helps,

Cor
Nov 17 '05 #2
Zen
It's easy to retrieve image from other sites and save them on disk.

To manage image and use database, please check out
www.aspsimply.com/aspnet/ImageDBASPX.aspx
www.aspsimply.com/aspnet/Thumbnail.aspx
www.aspsimply.com/vbnet/ImageDB.aspx

Zen

"news.microsoft.com" <jt****@gmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi, I am pretty new to ASP.net

I want to do the following but I have been unable to find good info/ or
sample code on it; please help;

- retrieve a gif/jpeg image using ASP.net from another site

- using ASP.net (Visual Basic.net or C#) code I want to edit the image by
superimposing a smaller image on the lower right hand corner

- then display the image to the user

- if possible, store the image to MySQL server

Thank you in advance. and please be as detail as you like.

Joe.

Nov 17 '05 #3

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

Similar topics

9
by: Pierre Tremblay | last post by:
Hi! I am trying to display an image in my html document. The document contains the following line: <td class="Input"><img...
5
by: news | last post by:
Hi, I am pretty new to PHP I want to do the following but I have been unable to find good info/ or sample code on it; please help; - retrieve a gif/jpeg image using PHP from another site -...
2
by: Matt | last post by:
In the following code, I have 2 questions regarding submit button with image. 1) Does this code <input type="image" name="populate" src="populate.gif"> behave the same as an HTML submit button...
2
by: news.microsoft.com | last post by:
Hi, I am pretty new to ASP.net I want to do the following but I have been unable to find good info/ or sample code on it; please help; - retrieve a gif/jpeg image using ASP.net from another...
4
by: Jake | last post by:
Does cookieless session state (with the sessionid embedded into the url) interfere with the browser's retrieval of cached images from one session to the next? Does the sessionid embedded into the...
7
by: BluDog | last post by:
Hi I am trying to store an image in an xml file, i vcan store it fine but the retreval is a bit of a problem: To String: Dim ms As New IO.MemoryStream Dim arrImage() As Byte...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
6
by: Daniel Fetchinson | last post by:
Hi all, There are a number of free tools for image matching but it's not very easy to decipher the actual algorithm from the code that includes db management, GUI, etc, etc. I have my own image...
21
by: DP | last post by:
Hi, I'm not sure if this is the right group to ask. I am developing a small image library and I don't know how to hide the actual path to the image. So I go to the stock photo library websites...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.