Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate + draw scaled bitmap clips bad in 1.68 #719

Closed
AndersMad opened this issue Dec 9, 2018 · 3 comments
Closed

Rotate + draw scaled bitmap clips bad in 1.68 #719

AndersMad opened this issue Dec 9, 2018 · 3 comments

Comments

@AndersMad
Copy link

AndersMad commented Dec 9, 2018

Description

When using rotate on canvas the draw bitmap - only when/with scaling - clips to un-rotated bound. This is new in 1.68 vs 1.60. I use this to handle images with EncodedOrigin.

Code

var orgW = 600, orgH = 200,
	newW =  20, newH =  60

// .. create canvas with 90 degrees rotated dimension (w = h = 20, h = w = 60).
// Basic rotate
canvas.Translate(info.Width, 0);
canvas.RotateDegrees(90);

// Draw scaled bitmap
canvas.DrawBitmap(bmp, 
  SKRect.Create(0, 0, orgW, orgH),									
  SKRect.Create(0, 0, newW, newH), paint);

Expected Behavior

Same as 1.60 - the bitmap is rotate and drawn.

Actual Behavior

The bitmap is clipped at height 20px as it is the width of the new canvas - as in it clips as it would/should BEFORE the rotate/translate.
So the clipping happens as if it did not rotate - there the image lay down and the height is the width.

Basic Information

  • Version with issue: 1.68.0
  • Last known good version: 1.60.3
  • IDE: VS.NET 2017/2019
  • Platform Target Frameworks: .NET 4.7.2
  • Target Devices: ASP.NET

Original file - use this:

left-original

Sample of rotated - clipped at the bottom:

left-rotated

@irv
Copy link

irv commented May 29, 2019

Does it help to do this, after rotating the canvas but before drawing the bmp?:

var region = new SkRegion();
// adjust the origin if you want it to be anywhere other than top left
region.SetRect(new SKRectI(0, 0 , newW, newH));
canvas.ClipRegion(region);

@AndersMad
Copy link
Author

thanks, but no dice - tried before and after the rotation (sry for the late reply!)

@AndersMad
Copy link
Author

AndersMad commented May 3, 2020

I'm terribly sorry!! - twas me! 😳 had a SKImageFilter.CropRect used by SKImageFilter.CreateMatrixConvolution that was using pre-swap w/h 🙄

@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants