Welcome Guest Search | Active Topics | Members

Brightness/Contrast without Roundtrip Options
Fedor
Posted: Monday, September 12, 2005 1:18:05 AM

Rank: Advanced Member
Groups: Administration , Member

Joined: 7/28/2003
Posts: 1,254
Points: -345
Location: WA, US
Hello Everyone,

Here is simple sample how to apply Brightness/Contrast without Roundtrip using remote scripting approach.

Here is screenshot:



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.


Fedor attached the following image(s):
BrightnessContrast1.jpg



Best regards,
Fedor Skvortsov
Users browsing this topic
Guest


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.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.