Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Wed, 20 Jul 2016 13:46:38 -0700 Organization: A noiseless patient Spider Lines: 51 Message-ID: References: <87twfk93vu.fsf@Equus.decebal.nl> <874m7k86ll.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 20 Jul 2016 20:46:39 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="fc10d1b501433caa198830294d826923"; logging-data="7830"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18n3FSdHpRyq6VIi5EEnWhI" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <874m7k86ll.fsf@Equus.decebal.nl> Cancel-Lock: sha1:wTZVgLbch1ZOFrVjDO88BC9TQZg= Xref: csiph.com comp.lang.java.programmer:35022 On 7/20/2016 12:14, Cecil Westerhof wrote: > On Wednesday 20 Jul 2016 19:02 CEST, Knute Johnson wrote: > >> On 7/20/2016 00:15, Cecil Westerhof wrote: >>> I need to crop some images and decide to write a Java program for >>> it. At the moment it is very rudimentary, I plan to add some >>> functionalities and because I have very little experience with GUI >>> comments on how to implement the GUI better are welcome. >>> >>> >>> At the moment it is build with my camera's in mind and cropping for >>> InstaGram, but when it is seen as useful I will make it more >>> generic. >>> >>> >>> I have a few problems, the most important are: >>> - After loading the first or a new image the first click makes the >>> image disappear and painted again. Subsequent clicks do not have >>> this problem. >> >> We'd need to see the code > > That is stupid: I thought I had pasted the link, but I did not. >:-( > > Here it is: > https://github.com/CecilWesterhof/JavaExamples/blob/master/CropImage/CropImage.java > I looked at your code and find it a bit disjointed (but I do have a rather linear outlook). I guess it really depends on what you ultimately are trying to do though. If I were going to write a GUI program to crop images today, I would: 1) have a dialog to load an image (you have that) and display it along with its current dimensions 2) have a method to scale the displayed image so that you can operate on images bigger than your monitor 3) use something along the lines of my CropComponent to visually crop the image, showing the dimensions of the crop 4) display the cropped image and its new dimensions, so it can be cropped again 5) have a dialog to save the cropped image (you have that) or get GIMP cause it does everything for free. You might look at GIMP for their interface, it is really quite good. The image is in its own dialog and all the tools are in a couple of others for handy access. Take a look at the Zoom options under the View menu to see what I mean about #2 above. -- Knute Johnson