How to save a 'div' as an image? [duplicate] - html

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Get image data in Javascript?
Hello,
I've got a single div, which has a background already defined (note: its a single layer, on tag, or body background-image), and has an overlaying HTML5 canvas element which will let me draw on top of the background image.
I'd like to know how (if its possible) to create a button which when clicked, will save a snapshot of the div on the server side.
Example situation: I load page - > I draw something within the div -> I click save - > I go to repository - > I see my drawing (with the background and the user created overlay).
My current server side infrastucture is WinServer 2008 R2, IIS7.5, MSSQL 2000 RTM DBMS, Classic ASP application layer... Anything else you'd like to know?
Thanks for the assist in advance... :-)

For as far as I know, there is no standard .Net function to capture HTML to an image. What you could do is taking a snapshot with an extension.
Maybe this article can help you out.

Alternatively, I managed to scrounge up an indirect answer from StackOverflow (Mods - I is sorry, please don't be banning me for not searching first...)
Answer source: "http://stackoverflow.com/questions/934012/get-image-data-in-javascript"
Once again, thanks to "Uw Concept" for the prompt responses, and thanks to "Mathew Crumley" for the original answer...
Again, mods, I is sorry... :-(

Related

Creating an interactable grid with CSS and HTML ONLY on a single image

I am in the process of setting up a website via Enjin's web hosting for a game server I run. I have an HTML module that will display a map of the island our game server takes place on, with a grid overlay already.
What I am trying to do (if possible), is to create a dynamic grid with css and html (javascript if needed) that overlays the grid of the image and highlights each cell as a user hovers over it, with a small pop-up with details on a specific coordinate (such as any bases, or other special information about a specific area)
I have tried looking around via google, but all searches come up with creating a grid out of multiple images (which is not what I am after), or using the area tag without much explanation on how to turn it into a fullout grid.
I am unfamiliar with how to approach this problem, and would like any input or advice if possible. Thanks!
NOTE: For those wishing to see the map in question I am using, to better help understand my question and assist me, please see here.

Hiding images from HTML code [duplicate]

This question already has an answer here:
Protect images download theory
(1 answer)
Closed 7 years ago.
I want to hide images from my HTML code. I've disabled right click, which is pretty easy however the page source can still be viewed. Is there a way to hide all images from the HTML code so that the images cannot be stolen from the source code?
I'm afraid that there isn't a way to 100% stop a user of your site from getting into the code.
Not sure what the images are for but a couple of things you can do are:
Watermark your images.
Obscure the link by converting it into hexadecimal. (More on this on Google)
Bury it in divs or a table
Use Low Res images.
But as you've already disabled right-clicking that stops casual users from taking them.
Your browser will always need som kind of source to view the image, so you'll always be able to find it in the source code. However, there are ways to make it a little bit more complicated.
For example, using PHP, you can load the image through a script to hide the real URL and prevent some users from seeing it.
But remember, if the image is visible on the page, there will always be ways to steal it.
If you publish something in the web, you can't restrict the user. They can save anything from your page to their computer. But you can use watermarks on your images but still the user can download but can't steal.
Other way is you can convert your image into data-uri so user can not download the image. But it has its own limitation. But it may worsen your site's performance depending on number of images and size of the image.

How do you turn on the camera flash without taking pictures? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
wp8 - Reflection API issue - Please check
I know you can control the camera flash but that only seems to actually turn on the flash when you take a picture or record video. I also found one other way to turn it on by focusing the camera.
Is there a way to turn the LED flash on without either of these battery intensive hacks?
Yep, it's possible to do that on WP8 using public APIs, please see my answer # Reflection failure when attempting to access Microsoft.Phone.Media.Extended
There's also a way to do that for WP7, see # http://www.locked.nl/wp7-flashlight-getting-started

Best Way For keep image from copying [duplicate]

This question already has answers here:
Closed 10 years ago.
We have a picture on Our website how can i prevent other users cant download this picture ?
is it possible or not ? if its not possible please give some ways to make harder the way of copy a picture
If you really want to prevent someone from stealing a picture, someone refer to someone that is bad with technology, here's some technic :
Place the image as CSS background instead
Put a transparent DIV over the image.
Disable right click
Watermark all your image
Disable direct image access
Use .htaccess to allow only your website to access your image
Embed the picture using flash or something similar
Consider this : what is on the Internet will be and always be "free" to every "thief".
EDIT Here's a technic used to convert torrent inside a PNG : http://stegtorrent.sourceforge.net/ You could do the reverse if your the FBI ! :) Store your image inside a diffrent type of file.
The user can copy it one way or another. One interesting way though is to use images as CSS background that makes it it a little harder than right click and save image.
<div style="background-image:theimage.png ;"></div>
But to the determined user there is not much you can do. when you share an image just assume someone will copy it. Otherwise don't share it.
Add this script to the body tag. This will disable the right click from which save is called.
Have a look at this post on stack overflow Disable mouse click outside cropped region

how to disable dragging of an html element (especially "img")?

i have a image that i don't want it drag-able or selectable so that no drag to other places on the page. how is that done?
If you want your visitors/users to see the resource on your page there is no way to stop them downloading it or saving it.
Possible options:
You can use JavaScript to prevent the context-menu popping up on right-click (related article: http://javascript.about.com/library/blnoright.htm).
You can cover the image with a transparent .png or .gif so that clicking on the image simple returns the transparent image.
But if the user can see the image on the webpage then it's already on their computer.
In reality this is far harder than you may think it will be, I assume you don't want people stealing your images which is a fair enough thing but just remember all the different ways in which someone can get an image from a web site. Your can catch the right click event and stop them at least doing that, but they can always just take a screenshot and save that instead. This is a slippery slope and it always ends the same way, if they really want to steal it, they're going to.
Since the image is just a binary data, and all the data is written on client PC's, for displaying reason it's up to th euser what they'll do with the data. There's no way you can prevent them from saving the picture displayed on a website.
All you might do is make it a little bit harder, by blocking right clicking on image, (displaying alert on right click, or something like this). But if the user really wants to save the picture they will do this anyway.
Why should you do it?
I can suggest a javascript that will able it: http://www.brownielocks.com/stopcopying.html
But every one, even with little experience can view the source and copy it. and even if you block them from viewing the source, they can use wireshark and get the picture directly. Even if you use flash to show the picture one can screen-capture the screen and retrieve the picture.
Put a watermark on the picture and use http://www.tineye.com/ from time to time and search for your picture. If you find others that use your picture - sue them. It is the most effective way.
It is impossible to prevent someone to store an image (or other resources) on their computer as others already have mentioned.
But another trick to make it harder (impossible for inexperienced people I guess) is to use CSS and background images:
<div style='background: url("myimage.gif");'></div>
The image is now on the background of the <div> block and cannot be dragged or right clicked in order to save it.
Using some coding knowledge it is possible to ind out the myimage.gif part, which can be added after the base URL in order download the image and save it. For example if the HTML page is at http://www.example.com/mypage.html the image could be found at http://www.example.com/myimage.gif
As I mentioned it is still possible to save the image, but for inexperienced people it is a lot harder.
Note: In this example the image is just put in the HTML tag, but with proper use of a CSS file, it is even harder to find for inexperienced people.
You cannot prevent a user from saving something from the web to his PC. The nearest thing that comes to my mind is the -moz-user-select CSS property... https://developer.mozilla.org/en/CSS/-moz-user-select
This javascript snippet does exactly what OP asks:
document.addEventListener("dragstart", preventDrag);
function preventDrag(event) {
event.preventDefault();
}