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: Can you resize with BufferedImage Date: Thu, 13 Apr 2017 11:10:08 -0500 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <871ssy10ub.fsf@Equus.decebal.nl> <87wpapzv42.fsf@Equus.decebal.nl> <2c781f24-6e80-4e00-b8db-cb507c2b2993@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 13 Apr 2017 16:07:04 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="9d479cf69a0d3028b4dd55b295547597"; logging-data="744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19l5QC9co6YWq8S4HL2rHEt" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <2c781f24-6e80-4e00-b8db-cb507c2b2993@googlegroups.com> Cancel-Lock: sha1:lCnkFiG1aQ0VWZjylJmm7KJnd2I= Xref: csiph.com comp.lang.java.programmer:36443 On 4/12/2017 10:20, Eric Douglas wrote: > > I've never used an AffineTransformOp. To change the size of an image > I just generate a new image of the width/height/transparency I want. > Then I get the Graphics of the new image, cast it to a Graphics2D, > create a new AffineTransform, and set the translate/scale/rotate I > want. Then I call .setComposite(AlphaComposite.SrcOver) on the new > image's Graphics2D, then just .drawImage() passing in the old image, > the AffineTransform I just created, and the observer (normally > null). > > Normally you want to maintain proportions, your x and y for the scale > are both Math.min(newWidth / originalImageWidth, newHeight / > originalImageHeight). > I've done it that way too. I don't really know which is faster. -- Knute Johnson