High dpi images.

[quote=269487:@Michel Bujardet]You know, that discussion about images reminds me very much of what happens in Web design. There are people who use much too big pictures and then their site crawls.

Picture optimization is a big part of performances.[/quote]

I just had the weirdest flashback to modem times, when you’d use a LOWSRC image in HTML to load a very low-res, low-depth image in place of the larger one that would take much longer to download (so the whole page could be laid out without waiting for color images to be downloaded).

Sam,
with regards to Xojo and pdf images, do you simply “Save As” pdf from within photoshop, or are there other intermediate steps which need to be taken, in order to get them to function correctly in Xojo?

Thanks.

[quote=269499:@Richard Summers]Sam,
with regards to Xojo and pdf images, do you simply “Save As” pdf from within photoshop, or are there other intermediate steps which need to be taken, in order to get them to function correctly in Xojo?

Thanks.[/quote]
Photoshop is a bitmap editor. If you need a PDF that’s scalable in that way the graphics needs to be created in a vector drawing application like Illustrator or similar.

Sorry, I meant to type illustrator :slight_smile:

Quick clarification, since this is a common misconception: Photoshop can do both but specializes in raster graphics (strictly speaking, as “bitmaps” are supposed to be single-bit rasters). It’s not specialized in vector data but understands and respects them. If you use smart objects (with, for example, vectors imported from other tools, fonts, etc.) those are exported from Photoshop as vector data as well.

Smart Objects can carry a lot in Photoshop, and the PDFs would keep resolution-independent.

Of course, the actual usefulness of this is very limited, but it’s still nice to know it’s there :slight_smile:

[quote=269522:@Eduardo Gutierrez de Oliveira]Of course, the actual usefulness of this is very limited[/quote]Exactly. That’s why I didn’t mention it :wink:

One last option I’ve used successfully in the past for very specific needs: For widgets and small, predefined objects, using a custom font goes a long way.

I have at least one application where I avoided most problems with UI Widgets in HiDpi by using a custom font with the widgets. The font rendering engine takes care of it.

For years I’ve used the vector tools within Photoshop and simply saved as a PDF file.

Don’t even own or rent Illustrator.

When you open a pdf as picture in Xojo it’s always rasterized at 72dpi size, at least on mac. To rasterize at other sizes I use declares for mac you can get here
https://forum.xojo.com/31393-how-to-get-a-high-resolution-picture-from-the-clipboard/
For Windows or Linux there might be declares floating around or there’s the MBS DynaPDF plugin.

Is it rasterized or does it use the preview thumbnail?

I haven’t used PDFs on xojo mac without declares for so long I no longer remember.

Same difference I believe. I don’t know what functions Xojo uses for loading pictures on mac but I suspect it’s one that returns the default raster for pdfs, which are 72 dpi. But maybe the default on retina is 144 dpi. Anyways, to get a custom size requires a different path to specify that size and there’s more ways to load a pdf than the declares I used.

Is this still the case with 2016r1? I’m using my own Retina Kit for handling Retina images and it works with PDF no problem, I think there’s even a demo in the Retina Kit demo project.

I’m slowly transitioning my in app icons over to PDF, for a small size 16x16 they can be bigger than a minified png, but when you add in 32x32. They can be about the same, with the advantage that I’ll never need to add a 48x48 or higher!

So yes, this weirdo overhere creates vector artwork in Photoshop, saves it as a PDF and then uses it in his Xojo made apps.

No, no it’s not! :slight_smile:

With HiDPI on pic=Picture.Open(aPDFfile) creates a Picture without a raster and renders crisply drawn at any size. The Width/Height and Horizontal/VerticalResolution still report the 72 dpi values but it’s preserving the resolution independent pdf data. Forget my declares, it’s built in now :slight_smile:

With HiDPI off you’ll get the 72 dpi raster.

No, no it’s not! :)[/quote]
Hallelujah!

[quote=269712:@Will Shank]No, no it’s not! :slight_smile:
With HiDPI on pic=Picture.Open(aPDFfile) creates a Picture without a raster and renders crisply drawn at any size.
[/quote]
That is fantastic! What a great find.
Not sure how to adjust size when using via .FromData yet though. Shouldn’t that do the same as Picture.Open?
Just dragging in a pdf and then this in the paint event of a canvas:

Dim newImg As New Picture(g.Width, g.Height) newImg = Picture.FromData(pdfPic) g.DrawPicture(newImg, 0, 0)
Draws it (awesome!) but at some default fixed size.

As fas as I recall, opening a PDF in a Xojo application draws that pdf to “fill the Canvas area”. Does it use 72 dpi ? I do not know, but if I enlarge the window (and its contained Canvas), the PDF displayed image grows too.

At last, I never heard of a preview saved in pdf.

on the other hand, Illustrator had (certainly still have) a preview saed in its eps file. Very usefull to place an image in a Quark XPress drawing area.

Hmm… Really? I didn’t know that. Well, learning every day.
Up till now, I went though all kind of hoopla to get pdf’s to draw as button glyphs. I never realized it was so easy.
I’ll have to play a bit more to make the resizing work but I’m happy so far. :slight_smile:

Yes, FromData will work the same as Open. To adjust the size you need to DrawPicture with the extra parameters, without them it draws at the default size. So to draw the pdf 3 times it’s default size

g.DrawPicture(pdfpic, 0, 0, pdfpic.Width*3, pdfpic.Height*3, 0, 0, pdfpic.Width, pdfpic.Height)

[quote]Dim newImg As New Picture(g.Width, g.Height)
newImg = Picture.FromData(pdfPic)[/quote]
You don’t need the first line. That’s creating a new raster Picture which is thrown away on the next line where the non-raster pdf Picture is returned. All you need is

Dim newImg As Picture = Picture.FromData(pdfData)

This works great!

Dim newImg As Picture = Picture.FromData(pdfPic) g.DrawPicture(newImg, 0, 0, g.Width, g.Height, 0, 0, newImg.Width, newImg.Height)
So cool, so much easier and great on HiDPI.
Tomorrow I’m going to replace all my 1x/2x glyphs with 1KB pdf’s. :slight_smile:
Thanks!

So now who’s the cranky weirdo in the corner, seems like all the cool kids wanna use PDF in their Xojo made apps. Next y’all be drinking tea with milk?