Results 1 to 3 of 3

Thread: Converting to 32bpp Bitmap

  1. #1

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Arrow Converting to 32bpp Bitmap

    As a side project and something to help me learn about graphics in .NET I decided to make a simple image filter.

    I have one problem, which is loading the image into a 32bpp bitmap which I can then manipulate. After drawing into the copied bitmap the image is stretched to about the top 3/4, in the correct dimensions.

    I've been trying to pinpoint the problem without success, so I was wondering if anyone could take a look. It's in C# 2.0.

    Thanks
    - P
    Attached Files Attached Files
    Last edited by penagate; Jan 10th, 2007 at 01:26 PM.

  2. #2
    Addicted Member
    Join Date
    Jan 2005
    Posts
    150

    Re: Converting to 32bpp Bitmap

    I could be wrong

    but I was experiencing a problem where I was cropping part of an image and saving the cropped part as a new bitmap. My problem was that the cropped part only took up around 1/4 of the new bitmap and the rest was blank.

    To resolve this I think I had to call the setresolution method of the new bitmap and supply values. I think I got the values from a horizontalresolution method and a verticalresolution method.

    It was a while ago I done this, I will check the code in work tomorrow to see exactly what i done

  3. #3
    Addicted Member
    Join Date
    Jan 2005
    Posts
    150

    Re: Converting to 32bpp Bitmap

    Code:
    string fullPathOfOriginalFilename = "c:\\soap\\100dpi.tif";
    //original file
    System.Drawing.Bitmap myBitmap;
    myBitmap = new System.Drawing.Bitmap(fullPathOfOriginalFilename);
    
    
    //size and position of area to be cropped
    int cropX = 100;
    int cropY = 100;
    int cropWidth = 100;
    int cropHeight = 100;
    
    
    //a rectangle to set the location and size from the source image
    Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
    
    
    //create a new bitmap with the width/height values
    Bitmap imgCropped = new Bitmap(rect.Width, rect.Height);
    imgCropped.SetResolution(myBitmap.HorizontalResolution, myBitmap.VerticalResolution);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width