Drawing full resolution on Retina in a canvas

I need to draw the content of a TextArea into a Canvas.

Problem is, the canvas does not seem able to display at the same resolution as the Retina screen.

I tried to copy to a second TextArea and drawinto a picture, then draw it at reduced size into the canvas backdrop (for some reason it did not work in Paint).

No dice: the canvas appears smudged, very far from the crisp rendition of the TextArea. Seems the canvas is not HiDpi, and works like it would on a regular screen.

What should I do ?

[code]Public Sub prepareBigText()
TABigText.width = Textarea1.width * 2
TABigText.height = Textarea1.height * 2
TABigText.StyledText.RTFData = TextArea1.StyledText.RTFData

if TextArea1.Text <> “” then
for i as Integer = 0 to TABigText.StyledText.StyleRunCount-1
TABigText.SelStart = TABigText.StyledText.StyleRunRange(i).StartPos
TABigText.SelLength = TABigText.StyledText.StyleRunRange(i).Length
TABigText.SelTextSize = TABigText.SelTextSize*2
next i
end if
TABigText.SelectionStart = 0
TABigText.SelectionLength = 0
dim picbigtext as new picture(TABigText.width,TABigText.height)
dim g as graphics = picbigtext.graphics
ClearFocus
TABigText.DrawInto(g,0,0)

dim CvsShowMeBackdrop as new Picture(CvsShowMe.width, CvsShowMe.height)
dim g1 as graphics = CvsShowMeBackdrop.graphics
g1.Drawpicture(picbigtext, 0, 0, CvsShowMe.width, CvsShowMe.height, 0, 0, picbigText.width, picbigtext.height)
CvsShowMe.backdrop = CvsShowMeBackdrop
CvsShowMe.Invalidate
End Sub
[/code]

New Textbox.xojo_binary_project.zip

I did a number of things, so I’m not sure what exactly goes wrong with your function. One big thing is I use BitmapForCaching to get a properly configured HiDPI picture to work with.

Here’s the updated example project: https://www.dropbox.com/s/om7qs96h845wvax/New%20Textbox.xojo_binary_project?dl=1

Edit: I did also fix the “canvas won’t draw in paint” issue :slight_smile:

In Showme.paint try :
if self.backdrop <> nil then g.DrawPicture(self.backdrop, 0, 0, me.Width, me.Height, 0, 0, self.backdrop.Width, self.backdrop.Height)

Thank you Tim :slight_smile: