|
I tried the following code on Vista (2GB RAM) and it worked fine
(took some grinding to create and compress that big image though! )
int imagewidth = 16762;
int imageheight = 23258;
Bitmap bmp = new Bitmap((int)imagewidth, (int)imageheight, PixelFormat.Format24bppRgb);
bmp.SetResolution(600, 600);
bmp.Save("e:\\alltogeher.tif", ImageFormat.Tiff);
I would guess either you're not getting enough memory to create that huge
bitmap or you're on a version of Windows that has a GDI+ limit on bitmap
dimensions.
The resolution is added to the bitmap's/file's metadata (for types that support it)
but it doesn't affect the size of the image.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply. I tried it on Vista and it works. Do you know a method to get it to work on Windows XP?
Ben
|
|
|
|
|
I'm not sure. Vista has a newer GDI+ version that is not available for
any pre-Vista OSs. I can't find any documented maximum bitmap dimensions
for GDI+.
Are you sure the system is able to get the 1GB chunk of memory needed for that
image? If so, does smaller dimensions work?
I would at least expect it to work with dimensions that fit in a 16 bit signed int,
like GDI.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have 2GB of memory in my system. The initial size of the pagefile is set to 756MB, the maximum size of the pagefile is set to 1512MB.
I'm not familar with C++. Do you think it is a .NET limitation and that it could be possible with C++. Do you have the code for me?
Ben
|
|
|
|
|
bverp wrote: Do you think it is a .NET limitation
I don't think so - you're using the same version of .NET on both platforms, right?
If smaller image dimensions works on XP, then that's the solution - you can't
use GDI+ for bitmaps that big...you'll have to use something else or write your own
image handling code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If you don't want to resize the images, the resolution is irrelevant. It's only used to convert between measurements in inches and pixels.
I see that you create a bunch of Bitmap objects that you never dispose. That's not good for the memory management.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello,
I am using the smtpclient class to deliver mail to an smtp server
but I want to know the statues of each recipient in my message whether it receives it or not. Ok, my question will be like this is the smtpclient class works in a transaction? which means that its only objective is to deliver the mail message to the smtp server and not to follow whether this server will send it or not?
Thanks.
Dad
|
|
|
|
|
hadad wrote: I want to know the statues of each recipient in my message whether it receives it or not.
You are sending an email. When you send an email do you get a notification if the client failed to receive it? How does that notification manifest itself?
You will only get an immediate notification if the connection to your immediate SMTP server fails. After that, if it fails you will get an email back - maybe, possibly, perhap, then again maybe not.
You might like to read up on how email works, then you will understand what limitations there are.
|
|
|
|
|
I'm writing a class that relies on a TcpClient. The class has a Connect() method that starts a new thread reading data from a server. If the Connect() method has previously been called and the TcpClient is in the process of connecting or is connected I want to throw an Exception. When the connection closes I want to dispose of any resources associated with the TcpClient. Is this the correct way to go about it? I'm guessing not.
using System;
using System.IO;
using System.Net.Sockets;
using System.Threading;
namespace foo
{
public class foo
{
bool b;
TcpClient tcpClient;
NetworkStream networkStream;
StreamWriter streamWriter;
StreamReader streamReader;
public void Connect(string addr, int port)
{
if (b) throw new InvalidOperationException();
Thread t = new Thread(new ThreadStart(delegate
{
try
{
b = true;
tcpClient = new TcpClient();
tcpClient.Connect(addr, port);
networkStream = tcpClient.GetStream();
streamReader = new StreamReader(networkStream);
streamWriter = new StreamWriter(networkStream);
while (tcpClient.Connected)
{
string s = streamReader.ReadLine();
// do some wacky stuff
}
try { streamReader.Close(); }
catch { }
try { streamWriter.Close(); }
catch { }
try { networkStream.Close(); }
catch { }
try { tcpClient.Close(); }
catch { }
b = false;
}
catch (Exception e)
{
try { streamReader.Close(); }
catch { }
try { streamWriter.Close(); }
catch { }
try { networkStream.Close(); }
catch { }
try { tcpClient.Close(); }
catch { }
b = false;
}
}));
t.Start();
}
}
}
|
|
|
|
|
Emil Müller wrote: I'm guessing not.
Why guess? There have been like a million articles and tutorials on the internet about Socket programming for years. Find some and read them. I imagine there are some here in the CodeProject articles.
led mike
|
|
|
|
|
SELECT product.name AS Name, product.[desc] AS Description, product.modelNo AS Model, category.categoryName AS Category, product.MRSP AS [MSRP ($)],
product.retailPrice AS [Retail Price], product.[image] AS [Image]
FROM (category INNER JOIN
product ON product.categoryID = category.categoryID)
When this is bounded to the datagridview, it shows the MRSP as the last column.. I want the image column to be the last
meaning
Name | Desc | Model | Category | MSRP($)| Retail PRice | Image
NOW IT IS
Name | Desc | Model | Category | MSRP($)| Image | Retail PRice
|
|
|
|
|
If, prior to binding the data set to the grid, you pre-define your collection of grid columns and their individual data bindings (DataPropertyName) in the order you want, and set the AutoGenerateColumns property of the datagridview to false, you should be fine.
I hope that makes sense.
|
|
|
|
|
once i set the AutoGenerateColumns to false, it does not show anything.
BTw i am using the tableAdapter in dataset.xsd.
i am not harding my coding inside my cs file
private void btnViewAll_Click(object sender, EventArgs e)
{
dataGridInfo.DataSource = null;
dataGridInfo.Rows.Clear();
BindingSource bs = new BindingSource();
bs.DataSource = this.productTableAdapter.GetData();
dataGridInfo.DataSource = bs;
}
|
|
|
|
|
benjamin yap wrote: once i set the AutoGenerateColumns to false, it does not show anything.
You also need to predefine the location of the columns in the grid either programatically, or by editing the columns collection directly in the grid. If you right-click on the grid, and select 'Edit Columns', you can add the columns you want and set various columns properties including, most importantly in your case, the 'DataPropertyName' which should be the name of the field as defined in the dataset/datatable being bound to the grid via the BindingSource.
|
|
|
|
|
I have class
FormData {
public System.Drawing.Font TextBoxFont;
}
I need to read/store this class in isolated storage in Winforms application and also in user settings.
Using
XmlSerializer formatter = new XmlSerializer(typeof(FormData),
"MyNameSpace");
causes exception
System.Drawing.Font cannot be serialized because it does not have a
parameterless constructor.
How to fix ?
Andrus
|
|
|
|
|
AndrusM wrote: How to fix ?
Well you are going to want to check out how to control Serialization, there are a number of ways. You probably want to start with this[^] You may end up implementing IXmlSerializable[^]
It shouldn't take you long to get up to speed, I have used it in the past and it's fairly simple.
led mike
|
|
|
|
|
When an exception in an event handler is not handled, where does it bubble up to?
It's not bubbling up to anywhere in my Windows Form app. The exception itself gets reported in the debugger output, and the event handler terminates at the offending line of code, and my program runs happily along its way - no "unhandled exception" message is displayed anywhere.
The code doesn't even stop when running hosted/in the debugger. If I wasn't watching the output window, I would have no idea the exception is being thrown.
Is this expected?
I can handle this, I guess, by carefully wrapping all the code in my event handler with Try/Catch. However, I wanted some exceptions to bubble up and be handled in my app - specifically, those *I* throw. But they go nowhere. And I'm realizing... where would they emerge, anyway?
|
|
|
|
|
I have had weirdness like this before when I attached the debugger to running code and there were PDB files from a different build (build and deploy on Monday, lose PDB files on Tuesday, add enough code [spaces] to change the file slightly, rebuild and try to attach to the process on Wednesday). The PDB are similar enough to allow the debugger to attach, but stepping through causes very odd behavior. Of course the solution for this is to either get the original PDB files, or rebuild the assembly and debug with the new ones.
I have also seen cases where the output window shows a slew of "MissingMemberExceptions" or other system looking exceptions that happen in the background and doesnt appear to affect my program's execution. I assume these are thrown by dependant or underlying assemblies and handled down there, before they bubble up to the calling application. The output window may just be blindly dumping any exception data from the CLR.
What kind of exception / details are in the window? Can you cut/paste that and a sample of the code that is executed right before and after the exception shows in the output window?
|
|
|
|
|
I am trying to create an excel chart using reflection. I need to show the chart on a separate form. The chart gets created accurately but the code throws error while copying it to clipboard. Here is the code peice I am using to copy chart to clipboard.
oChartArea = oXLChart.GetType().InvokeMember(
"ChartArea", BindingFlags.GetProperty, null, oXLChart, null);
---> Exception in the line below
---> Exception: Exception has been thrown by the target of an invocation.
---> Inner Exception: Select method of ChartArea class failed.
oChartArea.GetType().InvokeMember(
"Select", BindingFlags.InvokeMethod, null, oChartArea, null);
oChartArea.GetType().InvokeMember(
"Copy", BindingFlags.InvokeMethod, null, oChartArea, null);
oImage = new Bitmap((Image)Clipboard.GetImage());
oPic.Image = oImage;
oPic.SizeMode = PictureBoxSizeMode.AutoSize;
oPic.Left = 10;
oPic.Top = 20;
Clipboard.Clear();
Seeking your help....thanks
|
|
|
|
|
hello,
can i droppeddown all items that i have in a DataGridViewComboBoxCell ?
if it ComboBox we can only set
myComboBox.DroppedDown = true;
but how i can do that in DataGridViewComboBoxCell ?
Thank u
Regards,
Tomi
|
|
|
|
|
Where are your items stored? in c#
Why doesn´t work like that:
ComboBox_Country.Items.Add("France");
ComboBox_Country.Items.Add("Italy");
or in database?
nelsonpaixao@yahoo.com.br
|
|
|
|
|
Hi All,
My requirement is to read an image file from database and to save it as project file (.mpp) file in C# .Net
Many thanks in advance.
Thanks and Regards,
Hariharan C
|
|
|
|
|
Ok, thats your requirement, where's your code?
Write something, post it when it doesn't work and maybe someone will help you.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi All,
I am able to read the file from database and save it as a mpp file. But when i tried to open in MS Project, its saying the following error,
"Project cannot recognize this file format"
The following is my code,
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection("data source=hariharan;
initial catalog=ProjectServer;
integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("select reserved_binary_Data
from MSP_PROJECTS where
proj_name = 'TestProject.Published'", con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter ada = new SqlDataAdapter(cmd);
ada.Fill(ds);
byte[] contentArray = (byte[])ds.Tables[0].Rows[0][0];
int len = contentArray.Length;
FileStream docStream = new FileStream("C:\\testing.mpp",
FileMode.CreateNew, FileAccess.ReadWrite);
docStream.Write(contentArray, 0, len);
docStream.Close();
con.Close();
Regards,
Hariharan.
|
|
|
|
|
Are you using the same byte encoding when saving and retrieving?
|
|
|
|