Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Fedor  
#1 Posted : Sunday, September 11, 2005 5:18:05 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,545

Thanks: 5 times
Was thanked: 58 time(s) in 57 post(s)
Hello Everyone, Here is simple sample how to apply Brightness/Contrast without Roundtrip using remote scripting approach. Here is screenshot: UserPostedImage And here is code:
Code:
<%@ Page language="VB" AutoEventWireup="false" %>
<%@ Register TagPrefix="cc1" Namespace="Aurigma.GraphicsMill.WebControls" Assembly="Aurigma.GraphicsMill.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>WebForm1</title>
		<script runat="server" language="VB">
Private imagePath As String = "TestImages/2.jpg" 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	If Not Page.IsPostBack Then
		BitmapViewer1.Bitmap.Load(Server.MapPath(imagePath))
	End If
End Sub

<RemoteScriptingMethod> _
Public Sub BrightnessContrast(brightness As Single, contrast As Single)
	'Reload image as image could be already changed
	BitmapViewer1.Bitmap.Load(Server.MapPath(imagePath))
	BitmapViewer1.Bitmap.ColorAdjustment.BrightnessContrast(brightness, contrast)
End Sub
		</script>
		<script>
function brightnessContrast_change(){
	//Brightness value
	var b=document.getElementById("brightness");
	var bValue=b.options[b.selectedIndex].value/100;
	//Contrast value
	var c=document.getElementById("contrast");
	var cValue=c.options[c.selectedIndex].value/100;
	
	var bitmapViewer1=document.getElementById("<%=BitmapViewer1.ClientID%>");
	bitmapViewer1.invokeRemoteMethod("BrightnessContrast", new Array(bValue, cValue))

}
		</script>
	</head>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			Brightness: 
			<select id="brightness" onchange="brightnessContrast_change();">
				<option value="100">+100</option>
				<option value="75">+75</option>
				<option value="50">+50</option>
				<option value="25">+25</option>
				<option value="0" selected>0</option>	
				<option value="-25">-25</option>
				<option value="-50">-50</option>
				<option value="-75">-75</option>
				<option value="-100">-100</option>
			</select>
			Contrast:
			<select id="contrast" onchange="brightnessContrast_change();">
				<option value="100">+100</option>
				<option value="75">+75</option>
				<option value="50">+50</option>
				<option value="25">+25</option>
				<option value="0" selected>0</option>	
				<option value="-25">-25</option>
				<option value="-50">-50</option>
				<option value="-75">-75</option>
				<option value="-100">-100</option>			
			</select>			
			<cc1:BitmapViewer id="BitmapViewer1" runat="server" Width="400px" Height="300px">			
			</cc1:BitmapViewer>
		</form>
	</body>
</html>
To speed up process it makes sense to set BitmapStateEnabled=false, as well as apply effects on small preview during editing.

Edited by user Monday, December 21, 2009 2:59:26 AM(UTC)  | Reason: Not specified

Fedor attached the following image(s):
BrightnessContrast1.jpg
Best regards, Fedor Skvortsov
Kartik Langalia  
#2 Posted : Friday, February 26, 2010 12:59:36 PM(UTC)
Kartik Langalia

Rank: Member

Groups: Member
Joined: 1/31/2010(UTC)
Posts: 11

Hi, Great Work, Sir!!! But it is not working with AjaxControls. Please help me. Thanks, Kartik Langalia
Tamila  
#3 Posted : Wednesday, March 03, 2010 3:17:15 AM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hello Kartik, The following code works with Graphics Mill AjaxControls. PLease try it.
Code:
<%@ Page Language="VB" AutoEventWireup="false" %>
<%@ Register Assembly="Aurigma.GraphicsMill.AjaxControls" Namespace="Aurigma.GraphicsMill.AjaxControls"
    TagPrefix="cc2" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <title>WebForm1</title>

    <script runat="server" type="text/VB">
        Private imagePath As String = "test22.jpg"

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                BitmapViewer1.Bitmap.Load(Server.MapPath(imagePath))
            End If
        End Sub

        <Aurigma.GraphicsMill.AjaxControls.RemoteScriptingMethod()> _
        Public Sub BrightnessContrast(ByVal brightness As Integer, ByVal contrast As Integer)
            'Reload image as image could be already changed
            BitmapViewer1.Bitmap.Load(Server.MapPath(imagePath))
            BitmapViewer1.Bitmap.ColorAdjustment.BrightnessContrast(brightness / 100, contrast / 100)
        End Sub
    </script>

</head>
<body>
    <form id="Form1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" />
    Brightness:
    <select id="brightness" onchange="brightnessContrast_change();">
        <option value="100">+100</option>
        <option value="75">+75</option>
        <option value="50">+50</option>
        <option value="25">+25</option>
        <option value="0" selected="selected">0</option>
        <option value="-25">-25</option>
        <option value="-50">-50</option>
        <option value="-75">-75</option>
        <option value="-100">-100</option>
    </select>
    Contrast:
    <select id="contrast" onchange="brightnessContrast_change();">
        <option value="100">+100</option>
        <option value="75">+75</option>
        <option value="50">+50</option>
        <option value="25">+25</option>
        <option value="0" selected="selected">0</option>
        <option value="-25">-25</option>
        <option value="-50">-50</option>
        <option value="-75">-75</option>
        <option value="-100">-100</option>
    </select>
    <cc2:BitmapViewer ID="BitmapViewer1" runat="server" Height="490px" Width="715px"
        ZoomMode="BestFit">
    </cc2:BitmapViewer>

    <script type="text/javascript">
function brightnessContrast_change(){
    //Brightness value
    var b=document.getElementById("brightness");
    var bValue=b.options[b.selectedIndex].value;
    //Contrast value
    var c=document.getElementById("contrast");
    var cValue=c.options[c.selectedIndex].value;
    
    var bitmapViewer1 = $find("BitmapViewer1");
    var params=new Array();
    params.push(parseInt(bValue, 10));
    params.push(parseInt(cValue, 10));
    bitmapViewer1.invokeRemoteMethod("BrightnessContrast", params)
}
    </script>

    </form>
</body>
</html>
Aurigma Support Team UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.