Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Help with graphics transforms

Back to Forum: Tech Off
  • User profile image
    raptor3676

    Hi, Everybody

    I need to draw on a bitmap through Graphics at an especific coordinate system using the Transform property on the Graphic object cause that way I can save a lot of lines.

    Look, the problem is easy: Let's say that I have a Bitmap, width W and Height H and I like to map their coordinate system from (0-W,0-H) to (minX-maxX,minY-maxY)

    This is what I've tried so far:

    Graphics g=Graphics.FromImage(img);
    g.TranslateTransform(-minX,-minY);
    g.ScaleTransform(W / (maxX - minX),H / (maxY -
    Does anyone knows how to do this right?

    Thanx in advance

  • User profile image
    Minh

    Try this:

    g.TranslateTransform(minX, minY);


    (no negate signs)

  • User profile image
    raptor3676

    Minh wrote:
    Try this:

    g.TranslateTransform(minX, minY);


    (no negate signs)


    No Minh, after several tries, finally I could have the damn thing working.

    g.TranslateTransform(-minX,-minY, MatrixOrder.Append);
    g.ScaleTransform(W / (maxX - minX),H / (maxY - minY), MatrixOrder.Append);

    This all that was needed.


    Thanx ALOT minh!!!

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.