[Webinar] Streamline your web hosting managementRegister Today

x
Solved

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

Posted on 2010-04-05
Medium Priority
1,090 Views
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

Y_axis,

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?

0
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
x3______x4

describing your 1st trapezoid, and DX, DH the transformation where the new trapezoid would be :
x1'=x1+DX
y1'=y1+DH
x2'=x2+DX
// and since bottom line does not move :
x3'=x3
x4'=x4

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
0

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
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_25688579.html

0

## Featured Post

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
Course of the Month10 days, 8 hours left to enroll