Click here to Skip to main content
15,907,497 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF crop image help!! Pin
siten030821-Dec-08 17:43
siten030821-Dec-08 17:43 
AnswerRe: WPF crop image help!! Pin
Christian Graus22-Dec-08 0:32
protectorChristian Graus22-Dec-08 0:32 
GeneralRe: WPF crop image help!! Pin
siten030822-Dec-08 6:19
siten030822-Dec-08 6:19 
GeneralRe: WPF crop image help!! Pin
Mark Salsbery22-Dec-08 6:42
Mark Salsbery22-Dec-08 6:42 
GeneralRe: WPF crop image help!! Pin
siten030823-Dec-08 10:27
siten030823-Dec-08 10:27 
QuestionRe: WPF crop image help!! Pin
Mark Salsbery23-Dec-08 12:19
Mark Salsbery23-Dec-08 12:19 
GeneralRe: WPF crop image help!! Pin
Pete O'Hanlon23-Dec-08 23:03
mvePete O'Hanlon23-Dec-08 23:03 
GeneralRe: WPF crop image help!! Pin
siten030824-Dec-08 6:11
siten030824-Dec-08 6:11 
Hey guys,

Thanks for the information, Below is the code that is finally working, i decided to throw some stuff out such as the buttons and use the slider instead. But i have one problem, when you browse for the image and it uploads to the image object, for some strange reason it looks like it is already zoomed in, i want it to capture exactly how the image looks whenopening it in paint etc. I have the code below including the XAML to see if there is something i am doing wrong, thanks again and merry christmas eve everyone : )

code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace WPFcropimage
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{

}

private void _btnbrowse_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = "c:\\";
dlg.Filter = "Image files (*.jpg)|*.jpg|*.bmp)|*.bmp|All Files (*.*)|*.*";
dlg.RestoreDirectory = true;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string selectedFileName = dlg.FileName;
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(selectedFileName);
bitmap.EndInit();
_viewedPhoto1.Source = bitmap;
}
}

private void _btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}

private void Zoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{

}
}
}


XAML:

<br />
<Window x:Class="WPFcropimage.Window1" <br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <br />
Title="Window1" Height="370" Width="591"><br />
    <Grid Height="341" Width="579.942"><br />
        <DockPanel Margin="23,33,181,29"><br />
            <Slider x:Name="Zoom" DockPanel.Dock="Left" Value="1" Minimum="0.1" Maximum="5" Width="25" Orientation="Vertical" ValueChanged="Zoom_ValueChanged" /><br />
            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="270" Width="356"><br />
                <Image Stretch="None" Height="262" Width="349" Name="_viewedPhoto1" HorizontalAlignment="Center" Opacity="0" StretchDirection="UpOnly" VerticalAlignment="Center"><br />
                    <Image.LayoutTransform><br />
                        <ScaleTransform ScaleX="{Binding ElementName=Zoom,Path=Value}" <br />
ScaleY="{Binding ElementName=Zoom,Path=Value}"/><br />
                    </Image.LayoutTransform><br />
                </Image><br />
            </ScrollViewer><br />
        </DockPanel><br />
        <Button Height="38" HorizontalAlignment="Right" Margin="0,33,41,0" Name="_btnbrowse" VerticalAlignment="Top" Width="104" Click="_btnbrowse_Click">Browse for Picture</Button><br />
        <Button Height="38" HorizontalAlignment="Right" Margin="0,89,41,0" Name="_btnCrop" VerticalAlignment="Top" Width="104">Crop Picture</Button><br />
        <Button Height="37" HorizontalAlignment="Right" Margin="0,0,41,33.5" Name="_btnClose" VerticalAlignment="Bottom" Width="104" Click="_btnClose_Click">Close</Button><br />
        <Border Margin="53,37.5,175.942,33.5" Name="_border1" BorderBrush="Black" BorderThickness="2" /><br />
    </Grid><br />
indow><br />

QuestionBackground image issue Pin
hotthoughtguy20-Dec-08 4:18
hotthoughtguy20-Dec-08 4:18 
AnswerRe: Background image issue Pin
DaveX8621-Dec-08 5:08
DaveX8621-Dec-08 5:08 
QuestionCustom markup extensions in the VS wpf designer Pin
jamie55019-Dec-08 23:40
jamie55019-Dec-08 23:40 
AnswerRe: Custom markup extensions in the VS wpf designer Pin
Mark Salsbery20-Dec-08 9:30
Mark Salsbery20-Dec-08 9:30 
GeneralRe: Custom markup extensions in the VS wpf designer Pin
jamie55021-Dec-08 23:41
jamie55021-Dec-08 23:41 
GeneralRe: Custom markup extensions in the VS wpf designer Pin
Mark Salsbery22-Dec-08 6:30
Mark Salsbery22-Dec-08 6:30 
GeneralRe: Custom markup extensions in the VS wpf designer Pin
Mark Salsbery22-Dec-08 6:32
Mark Salsbery22-Dec-08 6:32 
GeneralRe: Custom markup extensions in the VS wpf designer Pin
jamie55022-Dec-08 15:16
jamie55022-Dec-08 15:16 
GeneralRe: Custom markup extensions in the VS wpf designer Pin
Mark Salsbery23-Dec-08 6:00
Mark Salsbery23-Dec-08 6:00 
QuestionBound ItemsControl doesn't refresh upon restoring a minimized window Pin
Steve McMohan18-Dec-08 11:25
Steve McMohan18-Dec-08 11:25 
AnswerRe: Bound ItemsControl doesn't refresh upon restoring a minimized window Pin
cechode18-Dec-08 13:30
cechode18-Dec-08 13:30 
GeneralRe: Bound ItemsControl doesn't refresh upon restoring a minimized window Pin
Steve McMohan22-Dec-08 1:40
Steve McMohan22-Dec-08 1:40 
GeneralRe: Bound ItemsControl doesn't refresh upon restoring a minimized window Pin
Steve McMohan22-Dec-08 19:34
Steve McMohan22-Dec-08 19:34 
QuestionSilverlight Spreadsheet Pin
Alixer18-Dec-08 6:09
Alixer18-Dec-08 6:09 
QuestionSlower WPF Performance after a button gets focus Pin
Qwentin18-Dec-08 2:29
Qwentin18-Dec-08 2:29 
AnswerRe: Slower WPF Performance after a button gets focus Pin
Mark Salsbery18-Dec-08 8:15
Mark Salsbery18-Dec-08 8:15 
GeneralRe: Slower WPF Performance after a button gets focus Pin
Qwentin18-Dec-08 22:05
Qwentin18-Dec-08 22:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.