Click here to Skip to main content
15,921,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Should I trust the compiler to optimise? Pin
javaman5925-Jul-05 17:52
javaman5925-Jul-05 17:52 
AnswerRe: Should I trust the compiler to optimise? Pin
EssOEss25-Jul-05 20:15
EssOEss25-Jul-05 20:15 
AnswerRe: Should I trust the compiler to optimise? Pin
Guffa26-Jul-05 3:26
Guffa26-Jul-05 3:26 
QuestionEfficient way to number x-y Axes? Pin
...---...25-Jul-05 13:27
...---...25-Jul-05 13:27 
AnswerRe: Efficient way to number x-y Axes? Pin
Christian Graus25-Jul-05 16:18
protectorChristian Graus25-Jul-05 16:18 
GeneralDAL or no DAL Pin
Tom Wright25-Jul-05 12:40
Tom Wright25-Jul-05 12:40 
GeneralRe: DAL or no DAL Pin
Christian Graus25-Jul-05 16:19
protectorChristian Graus25-Jul-05 16:19 
GeneralReturn an Image from a .DLL Pin
kim3er25-Jul-05 11:39
kim3er25-Jul-05 11:39 
Hi,

I was hoping you could help me with a problem I'm having. I am writing a .DLL that reorders and renames a folder of images using System.Drawing.Image and System.IO. The .DLL is called from a Windows form, which catches events as the .DLL processes each file. I'd like the Windows application to show the image that is currently being processd.

My solution has been to create an event that is triggered as each new image is identified, passing the image out. I cannot just pass out the actual image, as the calling application's picture box would lock the image so it couldn't be moved etc by the .DLL.

What I have done instead is to redraw the image as a smaller bitmap (to the dimensions of the picturebox), this works in as much as it doesn't lock the file, but the picture box is blank (though there is a bitmap being passed, according to the Auto dialog).

I've checked my bitmap code in a seperate application that doesn't rely on an external .DLL and it works.

I've successfully passed strings and integers out, that have then appeared in the appication.

I'd like to know if I'm doing this the best way and where I am going wrong, cheers!

Bitmap conversion code in .DLL, DoNextFile is the trigger.
System.Drawing.Image img = System.Drawing.Image.FromFile(sour_file);<br />
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(144, 108);<br />
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);<br />
g.DrawImage(img, 0, 0, 144, 108);<br />
<br />
DoNextFile(bmp);


Creation of the Trigger in .DLL
public delegate void NextFile (System.Drawing.Image img);<br />
public event NextFile Next;<br />
<br />
private void DoNextFile(System.Drawing.Image img)<br />
{<br />
	if (Next!=null)<br />
	Next(img);<br />
}


Catch code in Windows app.
public void CatchNextFile (System.Drawing.Image img)<br />
{<br />
	if (pbxFile != null)<br />
	{<br />
		pbxFile.Dispose();<br />
	}<br />
	pbxFile.Image = img;<br />
	this.Update();<br />
}

GeneralRe: Return an Image from a .DLL Pin
EssOEss25-Jul-05 20:20
EssOEss25-Jul-05 20:20 
GeneralRe: Return an Image from a .DLL Pin
kim3er25-Jul-05 22:08
kim3er25-Jul-05 22:08 
GeneralRe: Return an Image from a .DLL Pin
kim3er26-Jul-05 7:24
kim3er26-Jul-05 7:24 
GeneralRemoving embedded newlines Pin
Dan Neely25-Jul-05 11:02
Dan Neely25-Jul-05 11:02 
GeneralRe: Removing embedded newlines Pin
EssOEss25-Jul-05 20:21
EssOEss25-Jul-05 20:21 
GeneralRe: Removing embedded newlines Pin
Dan Neely26-Jul-05 2:38
Dan Neely26-Jul-05 2:38 
GeneralForm Resize Pin
25-Jul-05 9:05
suss25-Jul-05 9:05 
GeneralRe: Form Resize Pin
KaptinKrunch25-Jul-05 10:09
KaptinKrunch25-Jul-05 10:09 
GeneralRe: Form Resize Pin
Yigal Agam25-Jul-05 10:15
Yigal Agam25-Jul-05 10:15 
GeneralRe: Form Resize Pin
twoteesbrett25-Jul-05 10:21
twoteesbrett25-Jul-05 10:21 
GeneralRe: Form Resize Pin
Yigal Agam25-Jul-05 10:26
Yigal Agam25-Jul-05 10:26 
GeneralRe: Form Resize Pin
twoteesbrett25-Jul-05 10:42
twoteesbrett25-Jul-05 10:42 
GeneralRe: Form Resize Pin
Dan Neely25-Jul-05 11:13
Dan Neely25-Jul-05 11:13 
Generalbutton haldling in c# Pin
iramg25-Jul-05 8:58
iramg25-Jul-05 8:58 
GeneralRe: button haldling in c# Pin
LongRange.Shooter25-Jul-05 9:33
LongRange.Shooter25-Jul-05 9:33 
Generalform size limits Pin
RedTurtle25-Jul-05 8:34
RedTurtle25-Jul-05 8:34 
QuestionHow to double-space a rich text box? Pin
EGosnell25-Jul-05 8:14
EGosnell25-Jul-05 8:14 

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.