|
Luc Pattyn wrote: ImageFormat.Jpeg would be more economical than ImageFormat.Png due to the compression used.
Actually you don't know that for sure, it depends on the images.. what if they're diagrams or pictures of text? The OP didn't say..
|
|
|
|
|
The OP stated "every bitmap in the memory takes about 10 times more then in the file" so I assume compression has been doing a fine job on his original images and stands a good chance of doing the same on the final images.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Fair enough, but, who knows right? PNGOUT-ed PNGs can be a lot smaller than PNGs compressed by the .NET PNG compressor..
|
|
|
|
|
given time the OP will tell.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
i need the png format because i'm useing the alpha channel. how does other programs do that ?
for example powerPoint ? in powerPoint i can put tens of images and the memory grows only with a few mb ?
|
|
|
|
|
Once you create the Bitmap object, in memory, the image is no longer compressed, but is a full 32-bit render of what the file says it should look like.
|
|
|
|
|
nryk wrote: private byte[] FileToByteArray (string path)
Just use the File.ReadAllBytes method.
nryk wrote: of course every bitmap in the memory takes about 10 times more then in the file
nryk wrote: i get a byte array that is about 10 times bigger
From that I can deduct that you either managed to change the image into an image that is ten times larger (e.g. three times larger in both x and y axis), or you have changed it into something that the Save method could not compress at all. Could you post example image files somewhere for examination?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i managed to see the problem: i'm loading jpg files, but in my app i need it as png file ( because of the alpha channel )so when i save it to the memoryStreem as ImageFormat.Png the png is less compressed,is it possible to compress the png file to something like 0.5 mb - 1 mb like jpg ?
|
|
|
|
|
That's hard when the source is a jpg. The PNG will preserve all the JPG compression artifacts resulting in a much bigger file (compared to what it would have been if the original source had directly been PNG-compressed) which essentially doesn't contain any extra useful information - except possibly for the Alpha channel (if present).
|
|
|
|
|
No, there is no lossy compression for PNG. The high compression rate of JPEG is simply done by throwing away the data that has least visual impact on the result.
It would of course be possible to write your own compression algorithm that does that, but it would be very hard to get the same quality - compression ratio as JPEG compression, as the compression used in a PNG is not at all designed for lossy compression.
Another alternative that is a bit more promising would be to extract the color data and alpha channel separately, and compress the color data as a regular JPEG image and the alpha data as a grayscale JPEG image.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Another alternative that is a bit more promising would be to extract the color data and alpha channel separately, and compress the color data as a regular JPEG image and the alpha data as a grayscale JPEG image.
and how do i do that ? and how do i combine them together later ? is it with LockBits? and run through every "Pixel" ? is there any other file type like png that have the alpha channel and still
remain small size ?
|
|
|
|
|
Yes, you would use LockBits to get access to the pixel data.
No, there isn't any image format with alpha channel and the compression ratio of JPEG, at least not supported by the .NET framework.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Is this still viable in VS2008 or is there a newer way to accomplish docking panels?
tia
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Others may offer alternatives, but as far as I know DockPanel Suite is still OK. On the other hand I have not looked around for some while.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks Henry;
I have not really seen any better alternatives but I am open to suggestions. I was not sure if MS had included this with 2008 or 2010.
thanks for the info
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Please help me on this code.
Am trying to load data from sql server 2005 express into textbox in visual c# 2008 express. I want the data to be displayed in the textbox from the first record in the database but am having this error message
"Ths best overload method match for 'system.data.sqlclient.sqlcommand.sqlcommand(string,system.data.sqlclient.sqlcommand)' has some invalid arguments.
Please help cos I dont know what to do about this.
Thanks
private void COMPANY_INFO_Load(object sender, EventArgs e)
{
btnAdd.Enabled = true;
btnCancel.Enabled = false;
btnUpdate.Enabled = true;
btnSave.Enabled = false;
SqlConnectionStringBuilder myBuilder = new SqlConnectionStringBuilder();
myBuilder.UserID = "sa";
myBuilder.Password = "admin123";
myBuilder.InitialCatalog = "Kay_Nylon_Db";
myBuilder.DataSource = "ADEMOLAPC";
myBuilder.ConnectTimeout = (30);
SqlConnection conn = new SqlConnection(myBuilder.ConnectionString);
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from Company_Info", myBuilder);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader["Company_Id"].ToString());
Console.WriteLine(myReader["Company_Name"].ToString());
Console.WriteLine(myReader["Company_Address_Line1"].ToString());
Console.WriteLine(myReader["Company_Address_Line2"].ToString());
Console.WriteLine(myReader["Fax"].ToString());
Console.WriteLine(myReader["Email"].ToString());
}
}
|
|
|
|
|
here is your problem. I think!
SqlConnection conn = new SqlConnection(myBuilder.ConnectionString);
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from Company_Info", myBuilder); <===== HERE
You have gone to all the trouble to create a connection, why not use it?
SqlCommand myCommand = new SqlCommand("select * from Company_Info", conn); <===== CHANGE TO
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you Henry.
I have fix the the error and there is no error now but cannot still load the record from data.
Pleas check the current code again.
private void COMPANY_INFO_Load(object sender, EventArgs e)
{
btnAdd.Enabled = true;
btnCancel.Enabled = false;
btnUpdate.Enabled = true;
btnSave.Enabled = false;
SqlConnectionStringBuilder myBuilder = new SqlConnectionStringBuilder();
myBuilder.UserID = "sa";
myBuilder.Password = "admin123";
myBuilder.InitialCatalog = "Kay_Nylon_Db";
myBuilder.DataSource = "ADEMOLAPC";
myBuilder.ConnectTimeout = (30);
SqlConnection Conn = new SqlConnection(myBuilder.ConnectionString);
Conn.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from Company_Info", Conn);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader["Company_Id"].ToString());
Console.WriteLine(myReader["Company_Name"].ToString());
Console.WriteLine(myReader["Company_Address_Line1"].ToString());
Console.WriteLine(myReader["Company_Address_Line2"].ToString());
Console.WriteLine(myReader["Fax"].ToString());
Console.WriteLine(myReader["Email"].ToString());
}
}
|
|
|
|
|
You asked the very same question yesterday, here[^]. Next time, continue the same thread and post what you've tried. This code is slightly different from what you posted yesterday.
|
|
|
|
|
Thanks Dave. I kept working on the code that is why is changing until all the problems are resolve. As a beginner in C# is bound to happen this way am sure you as a professional will not make the mistakes am making.
|
|
|
|
|
hi dude try this code
using system.data;
using system.data.sqlclient;
////then you have to connect to the databse using the sqlconnection
sqlconnection cn=new sqlconnection("server=.;user=sa;pwd=admin123;database=Kay_Nylon_Db");
//you can repace the . with the server name which the database loaded n it
but if the database on the same Pc just write . it means local or this pc
//then you need the sqlquery
//if you are using just the select query use this code
sqlDataAdapter da=new sqlDataAdapter("select * from Company_Info",cn);
//now you need to fill the data into Dataset
Dataset ds=new DataSet();
da.Fill(ds,"Company_Info");
//now you have the Data In the dataset and you can display it where ever you want
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Company_Id"].ToString());
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Company_Name"].ToString());
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Company_Address_Line1"].ToString());
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Company_Address_Line2"].ToString());
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Fax"].ToString());
Console.WriteLine(ds.tables["Company_Info"].rows[0]["Email"].ToString());
///
try this code it's more easier and saving time
|
|
|
|
|
Thanks alamree am going to work on it now and let you know the outcome.
|
|
|
|
|
|
It depends, on what you mean by a little delay.
Don't forget that it has to find and load the file.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Don't use Media Player. If you want instantaneous sound, look into DirectSound in the DirectX SDK, for an easier version, the XNA Framework.
|
|
|
|