Click here to Skip to main content
15,919,500 members
Home / Discussions / C#
   

C#

 
AnswerRe: xml file vs .config Pin
Arun Jacob9-Sep-09 0:06
Arun Jacob9-Sep-09 0:06 
AnswerRe: xml file vs .config Pin
PIEBALDconsult9-Sep-09 6:43
mvePIEBALDconsult9-Sep-09 6:43 
AnswerRe: xml file vs .config Pin
vivasaayi11-Sep-09 1:00
vivasaayi11-Sep-09 1:00 
QuestionNetwork usage [modified] Pin
Jacobb Michael8-Sep-09 23:25
Jacobb Michael8-Sep-09 23:25 
AnswerRe: Network usage Pin
Dave Kreskowiak9-Sep-09 6:41
mveDave Kreskowiak9-Sep-09 6:41 
GeneralRe: Network usage Pin
Jacobb Michael9-Sep-09 22:44
Jacobb Michael9-Sep-09 22:44 
AnswerRe: Network usage Pin
carlecomm21-Sep-09 21:55
carlecomm21-Sep-09 21:55 
QuestionImage Crop Issue [modified] Pin
Programm3r8-Sep-09 23:14
Programm3r8-Sep-09 23:14 
Hi all,

I am trying to crop an image based on a transparent panel that I have placed on the image. The transparent panel is placed on the image control based on certain coordinates (selected by a user based on mouse events). This works fine.

Now I want to try and crop the piece where the transparent panel is located on the image, but I keep receiving an exception: OutOfMemoryException => rect is outside of the source bitmap bounds.

But why is this happening? (note: The image Bounds value of X and Y is 0 and the transparent panel width and height is in bounds with the height and width of the image) The transparent panel is located within the picturebox, shouldn't it be able to get the correct position Confused | :confused: ??
Here is the code ...

...
                TransparentPanel tmpPnl = e.ClickedItem.Tag as TransparentPanel;
                Rectangle rec = tmpPnl.Bounds;
                Bitmap bmpImage = new Bitmap(base.Image);
                Bitmap bmpCrop = bmpImage.Clone(rec, bmpImage.PixelFormat); // exception occurs here
...


FYI
That "out of memory" exception appears when you attempt to crop a piece of the image outside itself.

Eg: If the image is 800×600 and you go:

Bitmap b = CropBitmap(myPic, 700, 500, 200, 200);

That’ll try select from 700×500 to 900×700, which does not actually exist.


Many thanks in advance
Kind regards,


The only programmers that are better C# programmers, are those who look like this -> Green Alien | [Alien]



Java | [Coffee] Programm3r

My Blog: ^_^

modified on Wednesday, September 9, 2009 6:01 AM

QuestionRe: Image Crop Issue Pin
Programm3r8-Sep-09 23:55
Programm3r8-Sep-09 23:55 
AnswerRe: Image Crop Issue Pin
carlecomm21-Sep-09 21:49
carlecomm21-Sep-09 21:49 
AnswerRe: Image Crop Issue Pin
Rob Smiley8-Sep-09 23:56
Rob Smiley8-Sep-09 23:56 
GeneralRe: Image Crop Issue Pin
Programm3r9-Sep-09 0:14
Programm3r9-Sep-09 0:14 
GeneralRe: Image Crop Issue Pin
Rob Smiley9-Sep-09 0:36
Rob Smiley9-Sep-09 0:36 
QuestionRe: Image Crop Issue Pin
Programm3r9-Sep-09 1:35
Programm3r9-Sep-09 1:35 
AnswerRe: Image Crop Issue Pin
Luc Pattyn9-Sep-09 1:47
sitebuilderLuc Pattyn9-Sep-09 1:47 
GeneralRe: Image Crop Issue Pin
Programm3r9-Sep-09 1:54
Programm3r9-Sep-09 1:54 
AnswerRe: Image Crop Issue Pin
Rob Smiley9-Sep-09 2:22
Rob Smiley9-Sep-09 2:22 
GeneralRe: Image Crop Issue Pin
Programm3r9-Sep-09 2:54
Programm3r9-Sep-09 2:54 
QuestionProblem Sending Message from SERVER to CLIENT Pin
muhammad_umair8-Sep-09 23:09
muhammad_umair8-Sep-09 23:09 
AnswerRe: Problem Sending Message from SERVER to CLIENT Pin
monstale8-Sep-09 23:45
monstale8-Sep-09 23:45 
GeneralRe: Problem Sending Message from SERVER to CLIENT Pin
muhammad_umair9-Sep-09 0:19
muhammad_umair9-Sep-09 0:19 
GeneralRe: Problem Sending Message from SERVER to CLIENT Pin
monstale9-Sep-09 0:52
monstale9-Sep-09 0:52 
GeneralRe: Problem Sending Message from SERVER to CLIENT Pin
muhammad_umair9-Sep-09 1:43
muhammad_umair9-Sep-09 1:43 
GeneralRe: Problem Sending Message from SERVER to CLIENT Pin
monstale9-Sep-09 2:30
monstale9-Sep-09 2:30 
GeneralRe: Problem Sending Message from SERVER to CLIENT Pin
muhammad_umair9-Sep-09 2:44
muhammad_umair9-Sep-09 2:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.