|
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.
|
|
|
|
|
If the URL is hardcoded, then you could in theory use a background thread which loads it into a MemoryStream before you click play. Then you could set up a System.Media.SoundPlayer(Stream) instance when button1 is clicked. Load the rest of the file into the MemoryStream and invoke the Play method
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi All,
I have been studing some OOP books and some of them present this solution to break down an application beetween Presentation, Business and DB Layer.
Quick Example in pseudo-code
Business Layer
Class Customer
ID
Name
Surname
SaveCustomer {...}
void LoadCustomer(ID){
this = CustomerDB.LoadCustomer(ID)
}
end
DB Layer
Class CustomerDB
SaveCustomer{....}
Customer customer = LoadCustomer(ID){
//connect to a DB and load ID, Name, Surname
c = new Customer()
c.Name = DB.Name;
.....
return c
}
End
Here Class Customer delegate SaveCustomer, LoadCustomer to CustomerDB.
A presentation layer call would be
Custoer c = new Customer()
c.LoadCustomer(3)
print c.Name
Why do many books suggest this solution?
Personally I see these shortcomings
1) The Business Layers will not compile byitself, because has a reference to the DBLayer
2) The Customer object contains preperties that are not tipical of a Customer (Save, Load)
3) The Customer object is thightly coupled with CustomerDB
Would not be a better solution this one?
My solution
Class Customer
ID
Name
Surname
end
Class CustomerDB
Customer customer = Load(ID)
bool save(Customer customer)
end
and the presentation Layer will call
CustomerDB customerDB = new CustmerDB();
Custmer c = customerDB.Load(ID);
print c.Name
this way
1) The Business Layer is completely indipendent from the Business and Presentation Layer
2) It compiles byitself
3) The Customer Class does not have any strange property (Save, Load)
4) Customer is loosely cupled with CustomerDB
but
5) The presentation Layer must know about both business and DB Layer. (I don't like this)
What solution from a OOP programming is better?
Using the solution I suggested how can I let the presentation layer to be decoupled with the DB Layer?
Thanks
Pierpaolo
|
|
|
|
|
pierpaolo paparo wrote: What solution from a OOP programming is better?
You might want to look into IoC containers.
That way the dependecies are abstracted out elsewhere. Things become dependent on interfaces, noth the implementation. So long as you keep the same interface the implementation can change as much as it needs to. This also helps in testing as you can swap out the real database and use something else very easily.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
Hi Colin,
My understanding is that if I code the Customer Class
BusinessLayer
Class Customer
ICustomerDB _customerDB
Customer(ICustomerBD customerDB) {
_customerDB = customerDB
}
void Save()
_custmerDB.Save(this)
end
end
Interface ICustomerDB
void Save(customer Customer)
end
DATABASE LAYER
Class CustomerDB : ICustomerDB
void Save(Customer customer){
//some code to save Customer in the DB
}
end
PRESENTATION LAYER
CustomerDB customerDB = new CustomerDB()
Customer customer = new Customer(customerDB)
customer.Name = 'Mario'
customer.Save();
Injecting the ICustomerDB into the Customer class using the constructor,
I manage to separate the Business Layer and the DB Layer.
Is this right?
Thanks
|
|
|
|
|
Hello Experts!!
I got an above errro during running my project.i dont knw how to remove it....Please Help!!!!
|
|
|
|
|
|
SK Genius wrote: What was your program doing
Without seeing any code, I would say nothing most useful, but filling a stack.
Probable causes: an unbound recursion by
- a property calling itself instead of accessing a member variable;
- a method calling itself, never hitting the exit condition.
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.
|
|
|
|
|
Program doing sql connection n i got this error at this point--->
SqlConnection sqlcon = new SqlConnection("Data Source=localhost;Initial Catalog=DB;Integrated Security=True");
|
|
|
|