Cropping only righ and bottom

Hi all,
I'm, as many of the thread writers :), kind of new to java, but everyday i like this language more :) I'm trying to make an image crop with variables the user can input themselves, it works now but not completely. The image displays on screen but when the cropping starts only pixels from the right and from the bottom dissolve. I used the next code to accomplish this.
public Image Crop()
          int iw = this.image.getWidth(null);
          int ih = this.image.getHeight(null);
          BufferedImage buffImg = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_ARGB);
          Graphics2D CropIg = buffImg.createGraphics();
          buffImg = buffImg.getSubimage(1, 1, iw-HorCropVar, ih-VertCropVar);
          CropIg.drawImage(this.image, 0,0, this.label);
          setImage(Toolkit.getDefaultToolkit().createImage(buffImg.getSource()));
                        return Toolkit.getDefaultToolkit().createImage(buffImg.getSource());
       }Can anyone help me out with it? And does anyone know if i can (the way i use the crop method now) add a mouselistener to it, to decide the region to crop??
Thanks all!!

Well, when you do
buffImg = buffImg.getSubimage(1, 1, iw-HorCropVar, ih-VertCropVar);you are only adjusting the width and height, as your x,y position is
fixed at 1,1. So you only lose pixels on the right and bottom.
To use the mouse to select the region, you'll probably want to use a
MouseInputAdapter, which implements both MouseListener and
MouseMotionListener. You can use the mousePressed() method to determine
when the selection of an area has been started, the mouseDragged()
method to determine the area being swept out, and the mouseReleased()
method to determine when the selection has completed.
In your mouseDragged() method, you'll probably want to provide some
visual feedback that the selection is occurring; you can look [url http://java.sun.com/docs/books/tutorial/2d/index.html]here for
some possibilities on how to do this.
Good luck.
: jay

Similar Messages

  • Photos sent to Kodak iPhoto print services CROPPED on top and bottom

    What is the easiest way to avoid cropping of top and bottom of photos I send to Kodak print service? It is a 1019x2000 size jpeg photo, 320kb

    This is a long and skinny photo. You may need to actually put blank space in to get them to keep the entire length of the long side, i.e., If you are printing a 4 x 6, your picture will be 6" on the long side and 3.06" on the short side. If you add .47" of blank space at the top and bottom, you will fill out the entire 4 x 6 inch photo with your 2000 pixel dimension on the long side.
    (.47" is an extra 157 pixels top and bottom.)

  • How to get Border to draw only top and bottom?

    Does anyone know a way to get a Border to only draw on specific sides? i.e. create an EtchedBorder, then only have it draw the border on the top and bottom?

    You can easily make your own border class and draw it yourself. Open up the source for Etched Border, copy it to your own border class, then modify it. That is legal to do. Then, you can provide the ability to allow the sides to be painted as options to your class. It is actually pretty easy to do.

  • Getting flicker at top and bottom of screen - should I crop or zoom in?

    Hi all, this is related to another thread I have here but I wanted to ask specifically...what is better...cropping or zooming?
    I have just finished editing a long production in 16:9 and have been monitoring the edit process on a 16:9 television.
    When the finished product is watched on the 16:9 tv, there is no flicker evidentat either the top or bottom of the screen.
    When watched on a 4:3 television in letterbox mode, naturally the top and bottom edges are exposed and this presents some flicker at the top and bottom extremeties on some shots.
    I can get rid of this flicker on the edges without re-editing time-consuming scenes by either zooming in a fraction or cropping the finished video top and bottom by a factor of 4 using the motion settings.
    I have monitored the cropping method on the 16:9 screen and you cannot see it until it is cropped by a factor of 5, and of course on the 4:3 screen the cropping method will only mean there is slightly more black top and bottom on the letterbox effect.
    I guess zooming in to get rid of the flickering will mean the quality of the picture degrades a little so cropping would probably be best.
    Is this your opinion as weel?
    Thanks in advance.

    I guess zooming in to get rid of the flickering will mean the quality of the picture degrades a little...
    Yes, any picture re-sizing degrades the original.
    ... so cropping would probably be best.
    Yes. To avoid losing anything, you could always only crop the shots from the camera that has the flicker (might take a while).

  • Some fonts tops and bottom are cropped

    I've been working on this DVD menu and been having trouble with the fonts I want to use. The tops and bottoms of certain fonts get cropped. Some fonts don't have this issue, of course only the fonts I want to use! haha
    Does anyone know of a work around or a solution to this?
    Cheers.

    Forget the DVI to HDMI. You will either get overscan or bars around the picture. It will probably be slightly blurry and you will end up using the HDMI input for something else later anyways. Since you aren't sending audio out from the mac on that cable just go VGA. Skip the post-processing and don't give yourself a headache with any of the switchrez or other resolution changing applications. The only thing you might be able to do is get into the service menu of your television (read the warranty disclaimer) and adjust the geometry on the HDMI input (some televisions will let you do this). If so read up on it or you can brick your tv.
    Good Luck,
    -j

  • When i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    when i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    Have you upgraded to iPhoto 9.6 for compatibility with Yosemite? If not, try that first.
    It looks like iPhoto has lost the connection between the thumbnails and the original image files.
    This can be caused by a corrupted iPhoto library, or the originals have been deleted or moved.
    Try first to rebuild your iPhoto Library:
    If you do not have a current backup of the iPhoto library, make a copy of the library, but do not overwrite any previous backup.
    Launch iPhoto with the ⌥⌘-key combination (option-command) held down.
    Select "rebuild" from the first aid panel.  This may take a while for a large library.
    Can you now see your photos again?
    If not, rebuild the library with iPhoto Library manager as described by Old Toad:            Re: iphoto crashed

  • TS3999 In MONTH, (PC) iCal only clearly lists 2 items a day. The 3rd item is "faded" and bottom portion cut off, w/ a "more" triangle in the lower-right corner. How can I expand (vertically) so the 3rd line posts clearly, and ONLY shows "more" if 4+ event

    In MONTH, (PC) iCal only clearly lists 2 items a day. The 3rd item is "faded" and bottom portion cut off, w/ a "more" triangle in the lower-right corner. How can I expand (vertically) so the 3rd line posts clearly, and ONLY shows "more" if 4+ events?
    Better yet... as there's a lot of "wasted" space w/ too large Month title and empty space surrounding the Month title above and too much space surrounding the month/year slider bar below, how can I minimize these to allow me more usable / valuable calendar "contents" so I don't need to waste so much time clicking "more" just to see the bottom of the truncated third event and find out there are no 4+ events posted that date?  i.e. more "user-friendly" presentation?
    Thx!
    [email protected]

    In MONTH, (PC) iCal only clearly lists 2 items a day. The 3rd item is "faded" and bottom portion cut off, w/ a "more" triangle in the lower-right corner. How can I expand (vertically) so the 3rd line posts clearly, and ONLY shows "more" if 4+ events?
    Better yet... as there's a lot of "wasted" space w/ too large Month title and empty space surrounding the Month title above and too much space surrounding the month/year slider bar below, how can I minimize these to allow me more usable / valuable calendar "contents" so I don't need to waste so much time clicking "more" just to see the bottom of the truncated third event and find out there are no 4+ events posted that date?  i.e. more "user-friendly" presentation?
    Thx!
    [email protected]

  • Using the crop tool in Lightroom 5 I can only move and crop my photos from the top. Am I doing something wrong?

    I am new to Lightroom 5 and find I cannot crop my photos as easily as I did in iPhoto. I would like to be able to drag them if I choose a custom size or crop them from the bottom as well as from the top but my two sided arrow disappears when I work at the bottom of the photo. Am I doing something wrong?

    I would suggest you trash the prefs.
    Quit Lightroom
    Launch Finder and find the user Library by clicking the Go menu whilst holding down the Optn (alt) key (n.b. the library is hidden until you press the optn key) and inside the Library folder select the preferences folder. Then trash the following file:
    com.adobe.Lightroom5.plist
    Then re-launch Lightroom
    It’s then worth clearing each cache. Go to the top menu bar:
    Lightroom >> Preferences >> File Handling (tab)
    Click the Purge Cache button under Camera Raw Cache Settings; then click the Purge Cache button under Video Cache Settings. Finally click OK.

  • HT202879 how do i add a line to the top and bottom of a text box only

    i have a text box in my Pages document but i need to be able to add a line tot he top and bottom only to my text box. can i pleae get some help.

    Hello alegna23,
    To add a line just to the top and bottom of a text box, you will need to add the two lines as shapes.  Follow the steps below to add a line to your document:
    Add a shape
    Click Shape in the toolbar.Click the arrows to see more shape styles.
    Select a shape to add it to the page.
    In step 2, select a line and use the squares on the end of the line to help resize the line.  You can find the full article here:
    Pages Help for Mac - Add and edit shapes
    http://help.apple.com/pages/mac/5.0/#/tan9ad18c384
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • 4x6 print in PSE12:cannot crop thin white edge rt.side and bottom

    When printing 4x6 prints in PSE12, the print leaves a thin, white edge on the right side and bottom of the print. I have attempted to correct this through cropping, but the thin white edge remains. Computer is HP notebook running windows 7, printer is HP 7510. I should not have to cut the edge off the print to correct this. Please help!
    Thank you so much.

    Possibly a printer limitation. Check the printer driver for a 'borderless' setting and see if that makes any difference. Also check your photo paper size - 4" x 6" and 10cm x 15cm are often used interchangeably, but they are actually different sizes.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • In trying to edit my pics only the slide show pics is editing - not the main pic.  Trying to crop the pic and the whole main screen goes grey

    In trying to edit my pics only the slide show pics is editing - not the main pic.  Trying to crop the pic and the whole main screen goes grey

    Please check your Firefox Installation's version. (can be found by clicking the main menu, either clicking or hovering over the help button, and then clicking about firefox in the sub menu). depending on how long ago you set up sync you may still be using the older sync version. firefox 29 introduced a new (and might i add far less tedious) sync version. see [[How to update to the new Firefox Sync|this Mozilla support article]] for information on upgrading your sync to the new version.

  • Help! Saving a PDF out of Illustrator and the PDF is cropped on the right and bottom. Artboard size is fine.

    We're having a weird issue with Illustrator that rarely can be replicated. When we're saving a file as a PDF, sometimes the PDF gets cropped to the right and bottom and we're not quite sure why it's happening. Sometimes we'll just go an open the Illustrator file again and re-save and it's fine. Other times we may need to re-start the computer or re-start Illustrator and it's fine. Other times when we do all of the above, it still crops the PDF. I'm baffled as to what's happening.
    We're running 10.6.8 OS X and this is Illustrator CC.

    This is in Illustrator CC Version 17. It is fine when you open them back in Illustrator.  I have also noticed that from Illustrator if you do a 'Save As', select PDF, then select one of the PDF presets (I use 'Press Quality) the resulting PDF when opened in Reader displays how I want it, with the artwork as it was positioned on the Illustrator artboard (not cropped). If I then open in Illustrator again, make a change to the artwork, and select 'Save' (not 'Save As') when opened back in Reader the file is cropped again.

  • How to crop a QuickTime movie to delete black top and bottom areas?

    How to crop a QuickTime movie? I mean, a ".mov" movie that shows a black area on top and bottom, which I want to delete.
    I have tried with iMovie 8.0.5, yet its "Window - Cropping..." to fit, crop and Ken burns does not allow to select the area that I want, which is extra wide.
    Thanks.

    How to crop a QuickTime movie? I mean, a ".mov" movie that shows a black area on top and bottom, which I want to delete.
    Basically, you have two options. 1) You can use an application like MPEG Streamclip (free) which allows you to reset the top/bottom/left/right screen edges (i.e., crop the active viewing area) and then re-compress the remaining content as a new file (as recommended by QTKirk) or 2) if you have QT Pro, you can simply "mask" the player display which crops the display screen to the desired mask dimension and location within the original area. The advantage of the latter work flow is not having to re-compress the file which can be very time consuming. Since the latter method may seem confusing to some, I have prepared a "quickie" tutorial which may be able to "talk" you through the process:
    TUTORIAL T026: Using a Mask to Crop

  • Cropping when moving and resizing a cropping rectangle

    I created a program that crops an image and displays the cropped image but I'm trying to add more functionality
    by making it movable and resizable. The rectangle moves and resizes but it only crops an image when user draws the rectangle and not when moved or resized. I know that the X,Y, height and width position of the rectangle would need to be updated but I'm not
    sure how I can accomplish this being new to WPF. Below is my user control "CropControl and the code behind. Also, I'm implementing my code using MVVM framework.
    XAML: 
    <UserControl x:Class="Klein_Tools_Profile_Pic_Generator.CropControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:s="clr-namespace:Klein_Tools_Profile_Pic_Generator"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
    <ControlTemplate x:Key="MoveThumbTemplate" TargetType="{x:Type s:MoveThumb}">
    <Rectangle Fill="Transparent"/>
    </ControlTemplate>
    <!-- ResizeDecorator Template -->
    <ControlTemplate x:Key="ResizeDecoratorTemplate" TargetType="{x:Type Control}">
    <Grid>
    <s:ResizeThumb Width="3" Height="7" Cursor="SizeNS" Margin="0 -4 0 0"
    VerticalAlignment="Top"/>
    <s:ResizeThumb Width="3" Height="7" Cursor="SizeWE" Margin="-4 0 0 0"
    VerticalAlignment="Stretch" HorizontalAlignment="Left"/>
    <s:ResizeThumb Width="3" Height="7" Cursor="SizeWE" Margin="0 0 -4 0"
    VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
    <s:ResizeThumb Width="3" Height="7" Cursor="SizeNS" Margin="0 0 0 -4"
    VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>
    <s:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE"
    VerticalAlignment="Top" HorizontalAlignment="Left"/>
    <s:ResizeThumb Width="7" Height="7" Cursor="SizeNESW"
    VerticalAlignment="Top" HorizontalAlignment="Right"/>
    <s:ResizeThumb Width="7" Height="7" Cursor="SizeNESW"
    VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
    <s:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE"
    VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
    </Grid>
    </ControlTemplate>
    <!-- Designer Item Template-->
    <ControlTemplate x:Key="DesignerItemTemplate" TargetType="ContentControl">
    <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
    <s:MoveThumb Template="{StaticResource MoveThumbTemplate}" Cursor="SizeAll"/>
    <Control Template="{StaticResource ResizeDecoratorTemplate}"/>
    <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
    </Grid>
    </ControlTemplate>
    </UserControl.Resources>
    <Canvas x:Name="BackPanel"
    MouseLeftButtonDown="LoadedImage_MouseLeftButtonDown"
    MouseMove="LoadedImage_MouseMove"
    MouseLeftButtonUp="LoadedImage_MouseLeftButtonUp"
    Background="Transparent">
    <ContentControl x:Name="contControl" Visibility="Collapsed"
    Template="{StaticResource DesignerItemTemplate}">
    <Rectangle x:Name="selectionRectangle" Fill="#220000FF"
    IsHitTestVisible="False"/>
    </ContentControl>
    </Canvas>
    </UserControl>
    CODE BEHIND:
    namespace Klein_Tools_Profile_Pic_Generator
    /// <summary>
    /// Interaction logic for CropControl.xaml
    /// </summary>
    public partial class CropControl : UserControl
    private bool isDragging = false;
    private Point anchorPoint = new Point();
    private bool moveRect;
    TranslateTransform trans = null;
    Point originalMousePosition;
    public CropControl()
    InitializeComponent();
    //Register the Dependency Property
    public static readonly DependencyProperty SelectionProperty =
    DependencyProperty.Register("Selection", typeof(Rect), typeof(CropControl), new PropertyMetadata(default(Rect)));
    public Rect Selection
    get { return (Rect)GetValue(SelectionProperty); }
    set { SetValue(SelectionProperty, value); }
    // this is used, to react on changes from ViewModel. If you assign a
    // new Rect in your ViewModel you will have to redraw your Rect here
    private static void OnSelectionChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e)
    Rect newRect = (Rect)e.NewValue;
    Rectangle selectionRectangle = d as Rectangle;
    if (selectionRectangle != null)
    return;
    selectionRectangle.SetValue(Canvas.LeftProperty, newRect.X);
    selectionRectangle.SetValue(Canvas.TopProperty, newRect.Y);
    selectionRectangle.Width = newRect.Width;
    selectionRectangle.Height = newRect.Height;
    private void LoadedImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    if (isDragging == false)
    anchorPoint.X = e.GetPosition(BackPanel).X;
    anchorPoint.Y = e.GetPosition(BackPanel).Y;
    Canvas.SetZIndex(selectionRectangle, 999);
    isDragging = true;
    BackPanel.Cursor = Cursors.Cross;
    private void LoadedImage_MouseMove(object sender, MouseEventArgs e)
    if (isDragging)
    double x = e.GetPosition(BackPanel).X;
    double y = e.GetPosition(BackPanel).Y;
    contControl.SetValue(Canvas.LeftProperty, Math.Min(x, anchorPoint.X));
    contControl.SetValue(Canvas.TopProperty, Math.Min(y, anchorPoint.Y));
    contControl.Width = Math.Abs(x - anchorPoint.X);
    contControl.Height = Math.Abs(y - anchorPoint.Y);
    if (contControl.Visibility != Visibility.Visible)
    contControl.Visibility = Visibility.Visible;
    private void Image_MouseMove(object sender, MouseEventArgs e)
    if (moveRect)
    trans = selectionRectangle.RenderTransform as TranslateTransform;
    if (trans == null)
    selectionRectangle.RenderTransformOrigin = new Point(0, 0);
    trans = new TranslateTransform();
    selectionRectangle.RenderTransform = trans;
    trans.Y = -(originalMousePosition.Y - e.GetPosition(BackPanel).Y);
    trans.X = -(originalMousePosition.X - e.GetPosition(BackPanel).X);
    e.Handled = false;
    private void LoadedImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    if (isDragging)
    isDragging = false;
    if (contControl.Width > 0)
    //Crop.IsEnabled = true;
    //Cut.IsEnabled = true;
    BackPanel.Cursor = Cursors.Arrow;
    contControl.GetValue(Canvas.LeftProperty);
    // Set the Selection to the new rect, when the mouse button has been released
    Selection = new Rect(
    (double)contControl.GetValue(Canvas.LeftProperty),
    (double)contControl.GetValue(Canvas.TopProperty),
    contControl.Width,
    contControl.Height);

    Hello HotSawz,
    The ResizeThumb and MoveThumb is not in your code so I cannot compile. Anyway, it is not the problem.
    Anyway, can you clarify more details about "it only crops an image when user draws the rectangle and not when moved or resized", it is already normal behavoir for you to draw a rectangle and then move it. What kind of action do you want? Do you
    mean some controls like this:
    http://www.codeproject.com/Articles/23158/A-Photoshop-like-Cropping-Adorner-for-WPF
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Blur top and bottom when exporting to Mpeg2

    Hey guys, will be glad if you could help me.
    I shot some video at 1080P I've edited it on 720 P project (resuzed the shots) and now I want to export to Mpeg 2.
    As far as i know, if I'm exporting 16:9 to 4:3 the image will be stretched, cropped or fit to scale and will be with black bars at the top and bottom.
    After I've exported from Premiere I got the video with blurred top and bottom.
    I added captures of one frame and my export settings. Glad if someone could help me (hope im not doing things wrong).
    ** sorry for any English mistakes.

    I stand corrected!
    OK I checked last night when I go home from work...
    Still getting blur on top & bottom but only when in stop...  With 6.0.3 (Same as 6.0.4)
    My Quadro FX 4800 is using Nvidia 320.49
    Same senerio 16x9 footage brought into 4x3 session
    The work around I used for both 6.0.4  and 6.0.3 was to modify the aspect ratio to 16x9 which
    worked in both versions.

Maybe you are looking for

  • Cannot find the Recv Logical system in Distribution Model

    HI experts, Im triying a Idoc to file scenario, the logical system for PI and R3 has been already created and assinged for the appropriate clients. and i ve created the port from r3 using tcode we21 and in PI using idx1 and Idx2. The RFC destination

  • Keys are shown instead of blank text

    Having a problem in our production system. The report is showing Key values for the Blank text. If there is a text value, it is showing correctly. Problem is coming only in production. Appreciate any suggesations

  • Is it possible to can I get installments for macbook air?

    Hello. I'm a student in Arizona and I'm from Turkey. I'm living in a boarding school and I wanna buy a new macbook for my classes because my current one is 6 years old and started to working really slow with some other issues. I wanna know if it's po

  • I would like to know more about email notifications.

    When I enable email notifications for new form submission and also check "include submitted data" how is the submitted info shown on my email notification?

  • Need integration of sap with documentum

    can any one tell me how to integrate sap with documentum. need urgently. can any one tell me the procedure? thaks&regards, babu. <THREAD LOCKED. Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] to dis