473,396 Members | 1,784 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,396 software developers and data experts.

Clipboard Images

28
Hi everyone,
I am trying to get an imagefrom the clipboard.. The senario is the user presses printScreen button on the keyboard and captures an image then go to my web page and click a button and copies the image from the clipboard and saves it to the server....

I tried using javascript and it worked for Text but not for Images :(

does anyone knows a way to get it done????
Jun 8 '07 #1
12 2259
TRScheel
638 Expert 512MB
Hi everyone,
I am trying to get an imagefrom the clipboard.. The senario is the user presses printScreen button on the keyboard and captures an image then go to my web page and click a button and copies the image from the clipboard and saves it to the server....

I tried using javascript and it worked for Text but not for Images :(

does anyone knows a way to get it done????

You want this done in Javascript or ASPX?
Jun 8 '07 #2
richkid
28
any way is good for me !!!!
Jun 8 '07 #3
TRScheel
638 Expert 512MB
any way is good for me !!!!

In C# you can do this:
Expand|Select|Wrap|Line Numbers
  1. Image myImage;
  2. if (Clipboard.ContainsImage())
  3. {
  4.     myImage = Clipboard.GetImage();
  5.     // save image
  6. }
Havent tried it in ASPX though... would probably take some fiddling with to work right.
Jun 8 '07 #4
richkid
28
well thanx for that.....

it works but not for aspx no clipboard obj :(
Jun 8 '07 #5
TRScheel
638 Expert 512MB
well thanx for that.....

it works but not for aspx no clipboard obj :(
Well, I did some more research into your problem and came upon this:

ASPX Clipboard
Jun 11 '07 #6
richkid
28
well.. i tried something like that b4 but i think my problem is including the .dll

I created the .dll, set the COM visible and COM class to true, copy the .dll to the web folder, add a reference from a web page and still not getting it to show in the web page... what am i doing wrong?
Jun 11 '07 #7
TRScheel
638 Expert 512MB
well.. i tried something like that b4 but i think my problem is including the .dll

I created the .dll, set the COM visible and COM class to true, copy the .dll to the web folder, add a reference from a web page and still not getting it to show in the web page... what am i doing wrong?
Care to post your code?
Jun 11 '07 #8
richkid
28
I created anew Windows Control Library Project > add a button and picture box > add the following code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myImage As Image
Dim txt, path As String
path = "C:\Documents and Settings\SPY\Desktop\"

If Clipboard.ContainsImage() Then
myImage = Clipboard.GetImage()

'save image as jpeg
Dim myFormat As System.Drawing.Imaging.ImageFormat
myFormat = System.Drawing.Imaging.ImageFormat.Jpeg

myImage.Save(path & ".jpg", myFormat)
PictureBox1.Image = myImage

ElseIf Clipboard.ContainsText() Then
txt = Clipboard.GetText()
TextBox1.Text = txt

Else
Label1.Text = "Empty"
End If
End Sub


Next I run the program and get a .dll > Copy .dll to web folder > add the foll in source (html) of web page default.aspx :

<object id="myControl1" name="myControl1" classid="ScreenShot.dll#ScreenShot.ScreenControl" style="width: 572px; height: 460px">
</object>



Then add a reference to the .dll to the project


... get no error but not seeing anything on the web page!!
Jun 11 '07 #9
TRScheel
638 Expert 512MB
I am curious... try

Clipboard.SetText("This is from the clipboard")

then try and retrieve it. Something that small.

My bet is that the SetText call will throw an error.

If it does, please post the error. On continuation with that wager, it would have something to do with STA Thread or something similiar.
Jun 12 '07 #10
richkid
28
This is excerpts from the Windows Class that created the .dll;

Namespace ActiveXDotNet

Public Interface AxScreenCapture

Property Path() As String
Property FileName() As String

End Interface
End Namespace

Public Class ScreenCapture
'Inherits System.Windows.Forms.UserControl ', AxScreenCapture
Inherits System.Windows.Forms.UserControl
Implements ActiveXDotNet.AxScreenCapture

Private m_strPath As String
Private m_strFileName As String
Public strS As [String]

Public Property FileName() As String Implements ActiveXDotNet.AxScreenCapture.FileName
Get
Return m_strFileName
End Get
Set(ByVal value As String)
m_strFileName = value
End Set
End Property

//////////////////////////////////////////////////////////////////////////////////////////////////

I got the dll to work. seeing images now. Problem is to set the property on the control to a text via javascript (ex. passing a filename to property)



<object id="obj1" name="obj1" classid="GetImage.dll#GetImage.ScreenCapture" style="border-right: thin solid; border-top: thin solid; border-left: thin solid; border-bottom: thin solid; width: 480px; height: 400px;">
</object>
<input id="newButton" style="z-index: 102; left: 606px; position: absolute; top: 530px"
type="button" value="Click Me!!" onclick="doScript();"/>


<script type="text/javascript" >
function doScript()
{
obj1.FileName = "testing123"
// GetImage.ScreenCapture.FileName= "case5846"
}
</script>

//////////////////////////////////////////////////////////////////////////////////////////////////

The error message I am getting:

'obj1' undefined

Please help.
Jun 12 '07 #11
TRScheel
638 Expert 512MB
I dont profess to be a master of javascript, but I believe that you will have issues referencing obj1 directly because it is just an object, with no casting per say.
Jun 13 '07 #12
richkid
28
well finally i get this thing to show and i can now access the properties of the object using <param value>

I am trying to save the image on the server now i get the follow error::
System.Security.SecurityException:
Request for the permission of type 'System.Security.Permissions.FileIOPermission,msco rlib,Version 2.0.0.0, Culture = neutral, PublicKey Token = b77a5c561934e089' failed

any ideas?
Jun 15 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gey-Hong Gweon | last post by:
Is there a way to copy a PIL image to windows clipboard (as a dib image or a bitmap, I suppose)? What I would like to accomplish is to do a fast copy and paste of images from my python...
4
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: mhospodarsky | last post by:
Hi-- I am using VB.Net 2002 for this app. I am working with Tiff and jpeg images. I have a picturebox set up that I use to view the images. I have the picture box inside of a scrollable...
0
by: James Russo | last post by:
Hello, I have an application which requires an image to be retrived from the clipboard. So, I am writting a quick C# windows application to take images from a webcam and store a single frame on...
15
by: Peter Duniho | last post by:
I'm trying to use .NET and C# to draw a metafile copied to the clipboard by another application (Word 2003 in this case, but it shouldn't matter). I naively thought that I'd be able to use the...
5
by: exhuma.twn | last post by:
As many might know, windows allows to copy an image into the clipboard by pressing the "Print Screen" button on the keyboard. Is it possible to paste such an image from the clipboard into a "Text"...
20
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If...
23
by: Over | last post by:
Hi it's possible with language C, (Mingw or Djgpp) copying the clipboard of WinXp into file.txt? which function must be use. Thanks
8
by: kroogar | last post by:
Hi gurus .Net 2.0 I'm on a project where I need to be able to detect if my clipboard contains BOTH images AND text (eg. when copying from a web page). For some reason...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.