NSBitmapImageRep setSize: doesn't always do the right thing
NSBitmapImageRep setSize: doesn't always do the right thing
- Subject: NSBitmapImageRep setSize: doesn't always do the right thing
- From: Steve Mills <email@hidden>
- Date: Mon, 14 Mar 2016 19:55:32 +0000 (GMT)
I have some code that renders a MathML string into a WebView at a scaled-up size, then draws that into an NSImage of the scaled-up size, then draws that into a cropped NSImage to get rid of the extra space that the WebView throws in for scrollbars or whatever.
The cropped NSImage is created at the scaled-up size, drawn into, and finally the cropped NSImage's first NSImageRep is set to draw at the perceived, high-res size via [cropped.representations.firstObject setSize:perceivedSize]. This all works when the MathML string is long enough, but when it is short, it doesn't. The setSize ends up reducing the pixels, even though the image rep's pixelWidth and pixelHeight still report the correct high-res size.
Bug? It took me a few days to find the right combination of stuff to get the correct portion of the WebView and end up with a high-res image. I'm having to do all this with bitmaps because getting an EPS from the WebView via dataWithEPSInsideRect gives completely crappy and unusable results, like the top bar of the square root symbol isn't even connected to the √ part.
An example of one that works is 89px high and 349px wide at the scaled-up size (13px high x 50px wide at perceived size).
An example of one that does NOT work is 88px high and 107px wide at the scaled-up size (13px high x 16px wide at the perceived size).
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden