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

Source: Internet
Author: User

I've been working on this for a few days about the different order of the canvas method calls, and then I'll 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. But 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 just clipping the display area without polytopoly.

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

In this case, then talk about their own views on such effects, if there is anything wrong, users can leave a message to me.

The source code of 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, though, has changed the overall situation. But the display area remains the same.

The source code of 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. Just shows the picture display of 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, I want to make a polytopoly matrix change, but I want to see only the area of the transformation that I want to cut. So 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 clipping. The previous cut does not affect the transformation of the back artwork. Just fixed the display area.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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

Related Article

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.