The Cliprect and Concate call order of the canvas in Android results in different image effects.

Source: Internet
Author: User

These days I've been working on a test that has different effects on the canvas method call order.

As for the principle, the relationship between my canvas and matrix can see the reason. Or is everyone to try more, talent really understand thoroughly.

Next I explain the meaning of the first figure five tags;

The first order picture is normal full screen display on 800*1280 's phone. No task effect. Just the original is 720*1280, so in order to meet the cell phone screen size, he has to zoom in equal multiples.

The second order chart effect is the image after Polytopoly, no area clipping.

The third sequence diagram is to cut the display area first and then polytopoly the diagram later.

The IV sequence diagram is simply a clipping display area, without polytopoly.

The five sequence diagram represents the first Polytopoly and then the clipping area.

In that case, let's talk about your views on the effect. If there is any wrong place, the netizen can leave a message to me.

The source code for the Third Order diagram is:

Mbmp=bitmapfactory.decoderesource (Getresources (), R.drawable.guide_ PAGE01);
Canvas.save ();  
float src []={0,0,getwidth (), 0,getwidth (), GetHeight (), 0,getheight ()};
float sou[]={0,0, (float) (getwidth ()), (float) (+), (float) (getwidth ()), (float) (a), 0, (float) (GetHeight ())};
m.setpolytopoly (src, 0, sou, 0, SRC.LENGTH/2);

Canvas.cliprect (GetWidth ()/2-getwidth ()/6, GetHeight ()/2-getwidth ()/6, getwidth ()/2+getwidth ()/6, getheight ()/2+ GetHeight ()/6);
Canvas.concat (m);

Canvas.drawbitmap (Mbmp,0,0,null);
Super.ondraw (canvas);
Canvas.restore ();

I've cut the area I want to show, and I'm just showing the current area, no matter how the picture changes the matrix. So Polytopoly despite the changes in the global. But the display area remains the same.

The source code for the IV sequence diagram is:

Mbmp=bitmapfactory.decoderesource (Getresources (), R.drawable.guide_ PAGE01);
Canvas.save ();  
float src []={0,0,getwidth (), 0,getwidth (), GetHeight (), 0,getheight ()};
float sou[]={0,0, (float) (getwidth ()), (float) (+), (float) (getwidth ()), (float) (a), 0, (float) (GetHeight ())};
m.setpolytopoly (src, 0, sou, 0, SRC.LENGTH/2);

Canvas.cliprect (GetWidth ()/2-getwidth ()/6, GetHeight ()/2-getwidth ()/6, getwidth ()/2+getwidth ()/6, getheight ()/2+ GetHeight ()/6);
Canvas.concat (m);

Canvas.drawbitmap (Mbmp,0,0,null);
Super.ondraw (canvas);
Canvas.restore ();

Represents a matrix change that removes Polytopoly.

Only the display of the picture showing the clipping area.

The source code of the five sequence diagram is:

Mbmp=bitmapfactory.decoderesource (Getresources (), R.DRAWABLE.GUIDE_PAGE01);
Canvas.save ();
float src[]={0,0,getwidth (), 0,getwidth (), GetHeight (), 0,getheight ()};
float sou[]={0,0, (float) (getwidth ()), (float) (+), (float) (getwidth ()), (float) (0), (float) (GetHeight ())};
M.setpolytopoly (src, 0, sou, 0, SRC.LENGTH/2);

Canvas.concat (m);

Canvas.cliprect (GetWidth ()/2-getwidth ()/6, GetHeight ()/2-getwidth ()/6, getwidth ()/2+getwidth ()/6, getheight ()/2+ GetHeight ()/6);
Canvas.drawbitmap (Mbmp,0,0,null);
Super.ondraw (canvas);
Canvas.restore ();

He changes the Polytopoly matrix of the fourth sequence diagram. What he says is that I want to make a polytopoly matrix change, but the transformation area I want to see is just the area I want to cut.

So, for example, the effect of the following five order is presented.

A conclusion is drawn from the above: the Polytopoly matrix transformation is only effective for the subsequent graph shearing. The previous cut does not affect the transformation of the back artwork. Only the display area is fixed.

The Cliprect and Concate call order of the canvas in Android results in different image effects.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.