Blurry Drawpicture

  dim w as integer
  dim h as integer
  g.ForeColor=&c000000
  g.fillrect 0,0,g.Width,g.height
  w=xpic.Width
  h=xpic.Height
  g.drawpicture xpic,50,50,w*10,h*10, 0,0,w,h

In older versions of RealStudio this code gave a nice crisp exploded view of a picture with each pixel 10x its original size

but today in Xojo it produces a BLURRY picture as if it were trying to blend colors to make a “pretty” picture… which has its place of course
but is NOT what I want or need in this situation.

Interesting thing is if I add (and switch back to Carbon)

  g.useoldrenderer=true

just prior to the DrawPicture… I get exactly what I want… but the reason I am revisiting this project is to remove ALL deprecated features and convert it from CARBON to COCOA

Note : use of g.AntiAlias (true or false) has NO EFFECT on the output

left is what I want, right is what I get

Try:

xpic.Graphics.AntiAlias = False

and it should work.

[quote=71672:@Michael Thaler]Try:

xpic.Graphics.AntiAlias = False

and it should work.[/quote]

Nope… and didn’t think it would… AntiAlias should only affect drawing YET to be done… where Xpic has already been drawn… it is “G” that has not been drawn yet.

Xojo is anti-aliasing each pixel within itself… with no regard to the anti-alias flag.

What kind of image is xpic?

PNG… but that should be of no consequence… as it performs the same wrong way with JPG

It works fine under Carbon… or QuickTime if I invoke UserOldRenderer while in Cocoa…

AntiAlias works fine for drawing lines and shapes and text… but has NO EFFECT with DRAWPICTURE ( on seems to be the default)

FYI… expanding it in OSX PREVIEW also show the results I want… it is only XOJO that is “wrong”

I quickly tested it with an png file in all four combinations of RB / Xojo and Carbon / Cocoa: all blurry.

sorry I remembered wrong.
Here is the code that works for me.

Make a copy of your picture and set AntiAlais like this

[code]
dim p As Picture
p = newPicture( xpic.width, xpic.height, 32 )
p.Graphics.AntiAlias = False
p.Mask.Graphics.AntiAlias = False

p.Graphics.DrawPicture xpic, 0, 0
p.Mask.Graphics.DrawPicture xpic,0 , 0[/code]

Use this picture for your line:

g.drawpicture p, 50, 50, w*10, h*10, 0, 0, w, h

I hope it works for you too…

No… more over head… same results…

basically all that is doing is drawing it twice… once from Xpic to P, then from P to G
I am assuming you did not TRY the code, otherwise you would have seen this.

This DOES work under CARBON…if I set USEOLDRENDERER… but that forces use of QuickTime which has been deprecated
and it runs properly under WINDOWS as well.

Understand. The code I posted, works with Xojo 2013r4.
Didn’t try it with the newest release.

Ok… I would very much like to know what you did different…I just tried with 2013r4 and same blurry picture

I would post this to Feedback but that system seems to be on the fritz again… Tries to download a new version, and then won’t open it…

I have gone all the way back to 2012 and the ONLY way I can get what I need is to set USEOLDRENDERER

ANTIALIAS has no effect on DRAWPICTURE

Dave… if you are trying to install Feedback on Mac and it failed open Disk Utility and click eject on the Feedback volume then click on Feedback.dmg and Open it and it should work. (I had to do this the other day, I think something was messed up in the Feedback internal updater.)

Thanks Jason… that worked.

I looked again.
AntiAlias = False is important for drawing lines e.t.c.

For the scaling I used: ScaleImageAndMaskMBS

This should be the difference. Sorry for the mixup.

This is an issue that has been known to XOJO for a LONG TIME already
making it currently impossible for me to make this Apple Store ready.

There is an ImagePlayEffectsLibrary module (not my own) that offers a scaling method that should do what you want it to. Sample project here.

A non-plugin solution for you, because I have a feeling the MBS one isn’t helpful to you… For 10x scale, make a picture that is 10x the width and height of the original. Copy bits into it via RGBSurface, taking the x/10, y/10 pixel in the original for each pixel in the 10x scale copy. It’ll take 20x or more as long as a plugin, but you avoid having to use one.

-Brad

Thanks Jason… Brad… the code Jason pointed to does exactly that…

Unfortunatly, my application needs to have this done VERY VERY Fast… as it is a realtime “Magnify glass” view to a photo… the DRAWPICTURE scalling is quite fast enough, and so I will just stay with USEOLDRENDERER and stay of of the Apple Store until XOJO decides this is worth their time and effort

[quote=71713:@Dave S]Thanks Jason… Brad… the code Jason pointed to does exactly that…
[/quote]

I figured the “how it works” was important. My bad. Anyway, relevant to that other discussion, you’ve found a very good example of something you can’t do nearly as efficiently in Xojo as with a plugin. This simply has to do with pointer arithmetic and the ability to tell the C compiler that you’d like a pointer variable kept in a register while you iterate over a row. There are many, many other common development tasks where a lower level C implementation will smoke a Xojo implementation, and for which performance matters in the problem size your app can tackle.

Not true… .I found an example of where when Xojo implemented Cocoa they made a mistake.
And if I decide it is a big enough issue, I will write my own solution… as stated before… to me it is more important to learn (and yeah as a 58 year old IT professional I still do that)… than it is to get it done quickly.