Updating SaveAsPicture

another question about updating deprecated items

the following used to work (2007 RB)

    If f <> Nil Then f.SaveAsPicture p, 151

using the references i have changed it to the following

  If f <> Nil Then main.CanvasDD(4).Image.Save(f, Picture.Save)

but it says there is more than one item with this name. that’s not true

so what should i do?

  dim f as FolderItem = SpecialFolder.Desktop.Child("pic.png")
  
  dim p as new Picture (CanvasDD(4).Width, CanvasDD(4).Height)
  main.CanvasDD(4).DrawInto (p.Graphics, 0, 0)
  
  If f <> Nil Then 
    p.Save(f, Picture.SaveAsPNG)
  End If

The equivalent should be

if f <> Nil then p.save(f, 151)

axel

thanks for the details.

how can i assign the name and location of the png file?

the output file is blank. the right size but blank. does the picture need to be displayed on the screen to be copied? for me it is not when that part of the code is executed.

carl

Just to make sure I understand something here, doesn’t the usage of “DrawInto” only allow for saving of images at screen resolution (72dpi)?

i don’t know but if so, i need another way to create a higher quality image.
carl

[quote=161120:@Carl Mize]i don’t know but if so, i need another way to create a higher quality image.
carl[/quote]

Everything is a question of logic. Because images display in Xojo at 72 dpi, one may get the wrong impression that resolution is limited to 72 dpi.

In fact, Xojo can create images at any resolution, since it works in pixels, not dpi.

If I want a picture 7" x 3" at 600 dpi, all I have to do is to create it with width 4200, height 1800, and draw accordingly.

good point, michel, i would not have thought about that. i just need to include a note to tell the user to shrink the image.

as to copying from the screen, i can do the save after returning to the window that displayed it.

but i don’t know how to save the file with a name and location of my choosing.

appreciate the help

carl

Michel, this response from you involving a printing issue I had some time ago is where I got that impression.

Having tried writing the file after returning to the window with the picture, i realize that i want to add some to the picture. i need to be able to save a picture that will not appear on the screen. how do i do that.

carl

The printer graphic object is yet another potentially long story. You are right, I gave you an example using 72 dpi, as this is the default resolution for g. But it is more complicated than that. For instance, drawing fonts onto the printer object prints out at full printer resolution by default.

In fact, the printer setup lets you get the current printer resolution http://documentation.xojo.com/index.php/PrinterSetup which maybe much higher than 72 dpi.

In the post you refer to, I just tried to give you a quick way to obtain a nice printout. I am sorry if I gave you the impression you were limited to 72 dpi.

[quote=161160:@Carl Mize]but i don’t know how to save the file with a name and location of my choosing.
[/quote]

See http://documentation.xojo.com/index.php/Picture.Save

In the example, replace

f = SpecialFolder.Temporary.Child("TempImage.jpg")

by

f=GetSaveFolderItem(FileTypes1.Text,"Myfile.jpg")

FileTypes1 is a filetype control where you define the type of files to save.

This is not true. Or at least not on Windows. The Report subsystem may scale things for you, but if you simply open a printer and DrawString to it, you must scale the font yourself.

Strange. I have been selling Check Writer for Windows for over a year, and it does seem the MICR font prints at full resolution while all I did was to set g.TextSize to 12.

MICR fonts being particularly finicky in terms of dimensions, I can assure you it is conformant to the most stringent dimension requirements, and exhibits no jaggies.

Xojo carried that out for me :slight_smile:

Is it a true-type font?

Yes.
http://micr-fonts.com/MICRfont/micrfont.html

Incidentally, I have had a program, MICR Calibration Wizard, that prints a collection of MICR fonts and very fine lines secure numbers since late 2001 in RB that uses the same technique :
http://micr-fonts.com/MICRfont/micr-fonts-windows.html

Since it is used for calibration, resolution and dimensions suffer no error.

I was surprised long ago when I found out fonts printed at a higher resolution than the printer graphics object, but I was taught never to question miracles :wink:

No prob, Michel … sometimes learning is an “iterative” process. Whatever impression I had from a past input got refined with this discussion … translate that as “I’m continuing to learn, sometimes in steps over a period of time, but always appreciating your advice.” Heck, you have no idea how much that input you gave me on that print issue saved me some potential heartache … it got the job out the door and made my customer happy. What does MasterCard call that? … “Priceless”? ^^

I’ve not experienced that particular miracle.

To tell you the truth, if it did not work that way, I would probably be still using VB.

Glad it helped you get the project complete. Printing is sort of a hobby of mine. My very first commercial product was a Dos printer driver that allowed having accented characters and fonts over printers that did not support them. We are talking 1980 's :wink:

WARNING:

72 dpi was an Apple thing,
with HiDPI monitors, screen resolution can be higher than 72 dpi (OSX) or 96 dpi (Windows). I have 144 dpi on my MacBook Pro and 120 dpi on my Windows 8 laptop.