March 10th, 2008Employee Directory Photos on a Cisco IP Phone
Who cares that I don’t have a face? It’s still cool!
Below is the code I used to tap into the CIPIMAGE API and convert a .jpg image from our PeopleSoft database into a valid .cip image at runtime. Specifically it uses the “ImageProcessor” object to convert the image from a jpeg into XML data to be parsed by the phone.
This code will also require my Cisco Phone Object Class. The cipimage.dll is included in this post below. Be sure to register cipimage.dll on your web server!
Here’s the code:
Imports CiscoIPPhoneServices
Imports System.Data
Imports System.Data.SqlClient
Imports CIPIMAGE
Partial Class physdir_show_details
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ImgProc As New ImageProcessor
‘Establish connection with database
Dim SQLConnect As New SqlConnection(ConfigurationManager.AppSettings(“ConnectionStringName”))
Dim SQLCommand_Info As New SqlCommand(“stored_procedure_to_receive_info_from_db”, SQLConnect)
SQLCommand_Info.CommandType = CommandType.StoredProcedure
SQLCommand_Info.Parameters.AddWithValue(“@empid”, Request.QueryString(“empid”).ToString)
‘Prepare the table
Dim Adapter As New SqlDataAdapter(SQLCommand_Info)
Dim DT As New DataTable
Adapter.Fill(DT)
Dim EmpName As String = DT.Rows(0).Item(“EmployeeName”)
Dim pWidth As Integer = 52
Dim bEmpPhoto As Byte() = DT.Rows(0).Item(“EmpPhoto”)
ImgProc.LoadJPGFromBuffer(bEmpPhoto)
ImgProc.SetLocation(-1, -1)
ImgProc.Resize(52, 65)
ImgProc.ColorToGray()
ImgProc.ReducePaletteColors(4)
EmpPhoto = ImgProc.SaveCIPDataToBuffer()
EmpPhoto = Left(EmpPhoto, EmpPhoto.Length – 6)
Else
‘No photo Hex ASCII string
EmpPhoto = “<Insert a valid ASCII string for a picture that will display when the employee does not have a photo>”
EmpName = “No Photo Available”
pWidth = 87
End If
Response.Write(CIPPD)
End Sub
End Class
February 5th, 2009 at 1:07 pm
What did you use as stored procedure?I wondered “@empid” value
February 5th, 2009 at 2:42 pm
Gokce:
The empid comes from our PeopleSoft database. In fact, all of the information (name, department, phone number, and photo) comes from our database. In order for this to work you will need to be able to retrieve a photo. In this example, I am pulling the binary data for the photo out of the database.
February 5th, 2009 at 3:03 pm
Ok I got it,thank you.Actually I’ve got one more question.ı’m trying to write some codes about IP phone and I need some sample codes like these.Can you help me about it?
February 5th, 2009 at 3:04 pm
I don’t have ip phone now and I can’t be sure my codes without trying also:)I mean,I don’t know how can I use asp pages with ip phone..etc