Jump to content

Resize an Image

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
Ok, I've already figured out how to get an image and modify it by using the code found here:

http://forum.codecal...modify-bmp.html

Now my question is can I resize that image after all modification is done? This is to make the print-out fit a smaller label. I guess what I want to do is scale it down to the printer.

#2
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
I think I found your answer while searching for my answer (how to use an embedded font).

 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

using System;
using System.IO;
using com.lowagie.text;
using com.lowagie.text.pdf;

public class Chap0607 
{
	public static void Main(String[] args) 
	{
		Console.WriteLine("Chapter 6 example 7: Scaling an Image");
        
		// step 1: creation of a document-object
		Document document = new Document();
        
		// step 2:
		// we create a writer that listens to the document
		// and directs a PDF-stream to a file
		PdfWriter.getInstance(document, new FileStream("Chap0607.pdf", FileMode.Create));
        
		// step 3: we open the document
		document.open();
        
		// step 4: we add content
		Image jpg1 = Image.getInstance("myKids.jpg");
		jpg1.scaleAbsolute(97, 101);
		document.add(new Paragraph("scaleAbsolute(97, 101)"));
		document.add(jpg1);
		Image jpg2 = Image.getInstance("myKids.jpg");
		jpg2.scalePercent(50);
		document.add(new Paragraph("scalePercent(50)"));
		document.add(jpg2);
		Image jpg3 = Image.getInstance("myKids.jpg");
		jpg3.scaleAbsolute(194, 101);
		document.add(new Paragraph("scaleAbsolute(194, 101)"));
		document.add(jpg3);
		Image jpg4 = Image.getInstance("myKids.jpg");
		jpg4.scalePercent(100, 50);
		document.add(new Paragraph("scalePercent(100, 50)"));
		document.add(jpg4);

		// step 5: we close the document
		document.close();
	}
}

Source: http://www.ujihara.j...n/examples.html

#3
PC101

PC101

    Learning Programmer

  • Members
  • PipPipPip
  • 86 posts
When I click on this link...

http://forum.codecal...modify-bmp.html

I don't see anything. :(

Lyte

#4
Guest_CheeseBurgerMan_*

Guest_CheeseBurgerMan_*
  • Guests
The link works for me, but you can try the non-SEO'd URL.

http://forum.codecal...read.php?t=1077