Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2006, 06:35 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default GDI+ problem

Hi people,
I have few big problems that I can't resolve. I was codding for my graduation and with last two functions I have big problems. I wrote program for picture processing, and I stoped on functions for croping image and for skew. If somebody can help me, i'll be very thankfule. I have picture on what I've been processing in bitmap object, and I cant crop nor skew it
Help people please, it's very urgent! I must graduate in few days!
Tnx a lot!!!


 
Old February 12th, 2006, 06:49 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Submitting some source code would be a good idea..

Good luck on the graduation.

- A.Kahtava
 
Old February 12th, 2006, 08:04 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On example, function for Resize...
Code:
public static Bitmap Resize(Bitmap b, int nWidth, int nHeight)
{
    Bitmap bTemp = (Bitmap)b.Clone();
    b = new Bitmap(nWidth, nHeight, bTemp.PixelFormat);

    double nXFactor = (double)bTemp.Width/(double)nWidth;
    double nYFactor = (double)bTemp.Height/(double)nHeight;

    for (int x = 0; x < b.Width; ++x)
        for (int y = 0; y < b.Height; ++y)
            b.SetPixel(x, y, bTemp.GetPixel((int)(Math.Floor(x * nXFactor)),(int)(Math.Floor(y * nYFactor))));
    return b;
}
My idea was to submit to function my bitmap and points(for crop) or angle/points (for skew) and at the end to return bitmap for later save or use another funcion...

Ljuba

 
Old February 12th, 2006, 10:08 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

a couple questions:
Why are you using a static function?
How are you calling this function from your code?
Are you intending to change the value of Bitmap 'b' and later accessing it from your main?

Consider the following function:

public Bitmap Resize( Bitmap b, int nWidth, int nHeight )
{
  Bitmap result = new Bitmap( nWidth, nHeight );
  using( Graphics g = Graphics.FromImage( (Image) result ) )
    g.DrawImage( b, 0, 0, nWidth, nHeight );
  return result;
}

http://www.peterprovost.org/archive/2003/05/29/516.aspx

- A.Kahtava
 
Old February 16th, 2006, 05:27 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey,
tnx you, very very mutch
i'm sorry i little late with post, but i have a lot of work...

have anybody idea for function for skew... execly i need only formula for any angle...
i'll use next code:
Code:
PointF[] skewedCoordinates =
{
new PointF(boundsRectangle.Left,  boundsRectangle.Top),
new PointF(boundsRectangle.Right, boundsRectangle.Top),
new PointF(boundsRectangle.Left + boundsRectangle.Height, boundsRectangle.Bottom)
};
tnx






Similar Threads
Thread Thread Starter Forum Replies Last Post
GDI+ Problem -- Any Insight? dparsons ASP.NET 1.0 and 1.1 Professional 5 July 23rd, 2007 07:24 AM
GDI+ Help Dienzo General .NET 0 April 1st, 2007 02:50 PM
Device Independence in GDI+ Shujaat .NET Framework 2.0 0 November 24th, 2006 09:05 AM
EventHandler and GDI+ Function Fightfish C# 1 June 21st, 2005 08:02 AM
GDI+ in 2 forms clowns119 General .NET 0 March 18th, 2005 01:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.