[Webinar] Streamline your web hosting managementRegister Today


new Stretch Method,  Stretch a Trapezoid  but not a Retangle.

Posted on 2010-04-05
Medium Priority
Last Modified: 2013-11-23
new Stretch Method,  Stretch a Trapezoid  but not a Retangle.

i have been looking codes to Stretch a Trapezoid for a long time. Is there anyone can help me ?

i have a bitmap(ABmp), i draw a Trapezoid(Trapezoid_A) on it, the top and the bottom of the Trapezoid  always parallel


then i move the top of the Trapezoid   to any position(the length of the top keeps no change,and it always parallel Y_axis ).

now  a new Trapezoid(Trapezoid_B) formed by old bottom and the new top(the area of Trapezoid_B may less /more than the area

of Trapezoid_A ). what i need is Stretch Trapezoid_A into Trapezoid_B.

the function may like this
NewStretch(ABmp:TBitmap;                      //the source bitmap
           ATrapezoid:Array of TPoint;     //Old Trapezoid
           BTrapezoid:Array of TPoint;     //New Trapezoid
           BBmp:TBitmap                       //the Dest bitmap

by the way, the speed of the function is important, i have wrote one ,but it's too slow to use.
and you can use any component.

could you give me the code?

thank you in advance
Question by:bloodbird
LVL 25

Accepted Solution

epasquier earned 2000 total points
ID: 29915407
that is not very clear. What do you want ? to stretch the ATrapezoid shape in ABmp into BTrapezoid in BBmp ?
If ATrapezoid and BTrapezoid can be ANY kind of 4-points array, this would involve arduous calculation.
If you limit that to 2 sides // to X-axis (not Y, as you say it's top & bottom of it), then it would be better to say that your parameters are not 2 4-arrays of points but :

    x1,y1 ---x2
  /               |  h

describing your 1st trapezoid, and DX, DH the transformation where the new trapezoid would be :
// and since bottom line does not move :

which means that this is a normal stretch in height followed by a side-way shift (I don't know the correct term for this, think about pisa tower)

is that correct ?

what happens to other pixels (outside the trapezoid) in you dest bitmap ? all white ? what kind of pixel transformation do you want : closest pixel from source, pixel color calculation based on pixel resize & blending ? This alone will have huge impact on the quality of the result and the time to compute

Author Comment

ID: 31331750
epasquier:  i am very sorry for response you so slowly , that's because i post this question in a wrong place, i should post it in delphi programming zone ,this is the realted link


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article will show, step by step, how to integrate R code into a R Sweave document
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question