473,799 Members | 3,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send image to applet

Hi,

I wish to get the pixels os an image to transform it.

There is any posibility to do this with javascript ?

I have done with java, but I can't load web images from other http servers,
can I send the data of the image to the applet ?
Jul 23 '05 #1
3 2145
Jordan Gomila wrote:
I wish to get the pixels os an image to transform it.
There is any posibility to do this with javascript ?
I have done with java, but I can't load web images from
other http servers, can I send the data of the image to
the applet ?


The following code should help you:

<html>
<head></head>
<body>
<p><img name="sImg"
src="http://groups.google.b e/img/watched_y.gif"
width="18" height="18"></p>
<script language="javas cript">
if (document.image s) {
// show initial values of the image
showvalues();
// change width and height of image
document.images["sImg"].width=50;
document.images["sImg"].height=40;
// now read out values again
showvalues();
}
function showvalues() {
w = document.images["sImg"].width;
h = document.images["sImg"].height;
alert("Width is now "+w+" and height is now "+h);
}
</script>
</body>
</html>

--
Bart

Jul 23 '05 #2
Thanks, but I am not trying to change width and heigth. I am changing pixel
color.

I have done it with a java applet but I wish to allow to load images from
web, and as it is not allowed with untrusted applets I amb looking for other
alternatives.

Jul 23 '05 #3
Jordan Gomila wrote:
Thanks, but I am not trying to change width and
heigth. I am changing pixel color.
I have done it with a java applet but I wish to
allow to load images from web, and as it is not
allowed with untrusted applets I amb looking for
other alternatives.


Client side javascript actually can't *change* image properties. It can
only affect the way they are shown on the user's screen, which is a
significant difference.

It's not very clear to me what you mean by "changing pixel color".
There are some CSS/javascript possibilities that you could use/combine
to alter the image's appearance.

Maybe this could be a start:

<html>
<head>
<style>
div { width:200px;hei ght:200px;backg round-color: white; }
</style>
<script language="javas cript">
function alterpic(o,c)
{
if (document.image s) {
document.getEle mentById("back" ).style.backgro undColor=c;
document.images["sImg"].style.filter = "alpha(opacity= "+o+")";
document.images["sImg"].style.MozOpaci ty=o/100;
}
}
</script>
</head>
<body bgcolor="white" >

<p>
<div id="back" name="back"><im g name="sImg"
src="http://groups.google.b e/img/watched_y.gif"
width="200" height="200"></div>
</p>

<p>
<input type="button"
onClick="alterp ic('30','red')" value="Version 1">
<input type="button"
onClick="alterp ic('80','blue') " value="Version 2">
<input type="button"
onClick="alterp ic('40','green' )" value="Version 3">
<input type="button"
onClick="alterp ic('100','white ')" value="Original ">
</p>

</body>
</html>

Please note that you're on sensitive grounds here when it comes to
browser compatibility. I tested the code on latest IE and NS versions -
should be no problem there.

If you want to actually change your image, you should use a server side
approach. E.g. PHP/CGI with a call to GD/ImageMagick on Unix based
operating systems.

--
Bart

Jul 23 '05 #4

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

Similar topics

0
2764
by: Doug van Vianen | last post by:
Although I have programmed for several decades I am new to Java. I decided to learn it to create Applets to use in web pages I make as a volunteer in the computer club at a seniors' centre. My current learning project is to divide a picture into rows and columns of squares, then redisplay the picture with these squares positioned randomly in the rows and columns. In an applet I have stored the original picture as an image, divided it...
0
9876
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ********************************** package Celcom.Client;
4
5444
by: Rune Johansen | last post by:
Hi. I'm doing some image manipulation in an applet using the example code on this page: http://www.akop.org/art/pixels3.htm However, I really want an application rather than an applet, I just can't figure out how to do the image loading and manipulation when it's not from inside an applet. Any hints on the subject are appreciated.
1
4922
by: Wayne's World | last post by:
hi everyone, i have a big problem, writing a image from my applet to my apache webserver. i tried three way's of writing that file. every way was described in forums to solve this problem, but non of them worked and i don't know why. i'll give you the code of my writing-methods and describe, what happen when i test them, in order someone of you can give me a usefull tip, where the problem is. as inputparameter i give my method a new...
9
3241
by: takeiteasy | last post by:
Hello everyone, I've got a question about programming by using Java applet and the question is : Design a web page containing an applet that simply switches from one image to the next with some transition effects such as : Fade: Fade one image out while you fade the next one in. Whirlpool fade: Building on the fade transition, rather than just fading between images the first image swirls out of focus; the swirl is then reversed and...
1
1421
by: blek.najt | last post by:
Hello, is it posible to use an applet as an image source? something like <img src="document.myApplet.getImage()"> when getImage() function in the applet returns a png image as ByteArrayOutputStream ?
2
2344
by: final farewell | last post by:
Hello I am trying to do a simple java applet which loads image from a specified url. Here is the code I have now, but it cant seem to work. import java.applet.*; import java.awt.*;
2
1461
by: kaka123 | last post by:
Hi ive decided to make an applet where i would like my favorite player ed reed to run accross the screen with the ball in his hand, and i was wondering how i can animate him to do that..ive used the repaint function with a try sleep before so thats all i really am not sure how to do.. what would be a base code for this? im sure its hard if sice you dont have the file, but mabye you can give me a little back round thanks import...
2
7789
by: sandeepdhankar10 | last post by:
hi experts, i need ur help. i want to send a image via http post along with the form data i.e image name etc to a specified url .. which is the url of a jsp servelt. NOTE:- I am sending image from a JFRAME which is opened separately along with the applet.
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.