Please help me find problem in code :)

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Jul 2005
Posts: 1,542
Reputation: tayspen is on a distinguished road 
Solved Threads: 98
Team Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Please help me find problem in code :)

 
0
  #1
Aug 31st, 2005
this is the code

  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Runtime.InteropServices;
  11.  
  12. namespace WindowsApplication1
  13. {
  14. public partial class Form1 : Form
  15. {
  16.  
  17. public Form1()
  18. {
  19. InitializeComponent();
  20.  
  21.  
  22.  
  23. }
  24.  
  25. private void Form1_Load(object sender, EventArgs e)
  26. {
  27. // TODO:
  28. }
  29.  
  30. private void button1_Click(object sender, EventArgs e)
  31. {
  32. try
  33. {
  34. // Create the OpenFileDialog object
  35. OpenFileDialog myOpenFileDialog = new OpenFileDialog();
  36.  
  37.  
  38. myOpenFileDialog.Filter = "*.bmp|*.bmp|*.ico|*ico|*.jpg|*.jpg|*.gif|*.gif|*.pic|*.pic|*.tif|*.tif|*.png|*.png|*.qtif|*.qtif|*.*|*.*";
  39.  
  40. // Set properties appropriate.
  41. myOpenFileDialog.CheckFileExists = true;
  42. myOpenFileDialog.DefaultExt = "bmp";
  43. myOpenFileDialog.InitialDirectory = @"C:\";
  44. myOpenFileDialog.Multiselect = false;
  45.  
  46. // Use the OpenFileDialog and put the path and name of the
  47. // selected file in the txtFileName text box.
  48. if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
  49. {
  50. this.txtFileName.Text = myOpenFileDialog.FileName;
  51. }
  52. }
  53.  
  54. catch
  55. {
  56. //
  57. }
  58.  
  59. }
  60.  
  61. private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
  62. {
  63. //
  64. }
  65.  
  66. private void button2_Click(object sender, EventArgs e)
  67. {
  68. //
  69. }
  70.  
  71. private void txtFileName_TextChanged(object sender, EventArgs e)
  72. {
  73. //
  74. }
  75.  
  76. private void button3_Click(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80.  
  81. string J = Convert.ToString(txtFileName.Text);
  82. if (J == "") { }
  83. else
  84. {
  85. pictureBox1.Image = Image.FromFile(Convert.ToString(txtFileName.Text));
  86. }
  87. }
  88.  
  89. catch
  90. {
  91. //
  92. }
  93. }
  94.  
  95. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  96. {
  97.  
  98. //
  99.  
  100. }
  101.  
  102. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106.  
  107.  
  108. if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  109.  
  110.  
  111.  
  112.  
  113. File.Copy(txtFileName.Text, saveFileDialog1.FileName);
  114. }
  115. catch
  116. {
  117. //
  118. }
  119. }
  120.  
  121. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  122. {
  123. try
  124. {
  125. if (saveFileDialog2.ShowDialog() == DialogResult.OK)
  126.  
  127.  
  128. saveFileDialog2.Filter = "*.WPC|*.WPC";
  129.  
  130. File.Copy(txtFileName.Text, saveFileDialog2.FileName);
  131. }
  132.  
  133. catch
  134. {
  135. //
  136. }
  137. }
  138.  
  139. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  140. {
  141. try
  142. {
  143. if (saveFileDialog3.ShowDialog() == DialogResult.OK)
  144.  
  145.  
  146. saveFileDialog3.Filter = "*.WPC|*.WPC";
  147.  
  148. File.Copy(txtFileName.Text, saveFileDialog3.FileName);
  149. }
  150.  
  151. catch
  152. {
  153. //
  154. }
  155. }
  156.  
  157. private void button4_Click(object sender, EventArgs e)
  158. {
  159. try
  160. {
  161. }
  162. catch
  163. {
  164. MessageBox.Show("ERROR: Please make sure path is valid");
  165. }
  166. }
  167.  
  168. private void button5_Click(object sender, EventArgs e)
  169. {
  170.  
  171.  
  172.  
  173. //
  174.  
  175.  
  176.  
  177. }
  178.  
  179. private void button5_Click_1(object sender, EventArgs e)
  180. {
  181. if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  182. {
  183.  
  184.  
  185. }
  186.  
  187. }
  188.  
  189. private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
  190. {
  191.  
  192. }
  193.  
  194. private void label3_Click(object sender, EventArgs e)
  195. {
  196. //
  197. }
  198.  
  199. private void button4_Click_1(object sender, EventArgs e)
  200. {
  201. pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
  202. pictureBox1.Refresh();
  203. }
  204.  
  205. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  206. {
  207. try
  208. {
  209. if (saveFileDialog4.ShowDialog() == DialogResult.OK)
  210.  
  211.  
  212. saveFileDialog4.Filter = "*.WPC|*.WPC";
  213.  
  214. File.Copy(txtFileName.Text, saveFileDialog4.FileName);
  215. }
  216.  
  217. catch
  218. {
  219. //
  220. }
  221.  
  222. }
  223.  
  224. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  225. {
  226. try
  227. {
  228. if (saveFileDialog5.ShowDialog() == DialogResult.OK)
  229.  
  230.  
  231. saveFileDialog5.Filter = "*.WPC|*.WPC";
  232.  
  233. File.Copy(txtFileName.Text, saveFileDialog5.FileName);
  234. }
  235.  
  236. catch
  237. {
  238. //
  239. }
  240.  
  241. }
  242.  
  243. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  244. {
  245.  
  246. try
  247. {
  248. if (saveFileDialog6.ShowDialog() == DialogResult.OK)
  249.  
  250.  
  251. saveFileDialog6.Filter = "*.WPC|*.WPC";
  252.  
  253. File.Copy(txtFileName.Text, saveFileDialog6.FileName);
  254. }
  255.  
  256. catch
  257. {
  258.  
  259.  
  260. }
  261.  
  262. }
  263.  
  264. private void checkBox7_CheckedChanged(object sender, EventArgs e)
  265. {
  266.  
  267. try
  268. {
  269. if (saveFileDialog7.ShowDialog() == DialogResult.OK)
  270.  
  271.  
  272. saveFileDialog7.Filter = "*.WPC|*.WPC";
  273.  
  274. File.Copy(txtFileName.Text, saveFileDialog7.FileName);
  275. }
  276.  
  277. catch
  278. {
  279.  
  280. }
  281.  
  282. }
  283.  
  284. private void checkBox8_CheckedChanged(object sender, EventArgs e)
  285. {
  286. try
  287. {
  288. if (saveFileDialog8.ShowDialog() == DialogResult.OK)
  289.  
  290.  
  291. saveFileDialog8.Filter = "*.qtif|*.qtif";
  292.  
  293. File.Copy(txtFileName.Text, saveFileDialog8.FileName);
  294. }
  295.  
  296. catch
  297. {
  298.  
  299. }
  300.  
  301. }
  302.  
  303. private void customConversionToolStripMenuItem_Click(object sender, EventArgs e)
  304. {
  305.  
  306. try
  307. {
  308. if (saveFileDialog9.ShowDialog() == DialogResult.OK)
  309.  
  310.  
  311. saveFileDialog9.Filter = "*.qtif|*.qtif";
  312.  
  313. File.Copy(txtFileName.Text, saveFileDialog9.FileName);
  314. }
  315.  
  316. catch
  317. {
  318.  
  319. }
  320.  
  321. }
  322.  
  323. private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
  324. {
  325. MessageBox.Show("Image Tweaker: By GHOST");
  326. }
  327.  
  328. private void pictureBox1_Click(object sender, EventArgs e)
  329. {
  330.  
  331. }
  332.  
  333. private void copytoClipboardToolStripMenuItem_Click(object sender, EventArgs e)
  334. {
  335. DataObject myDataObject = new DataObject();
  336. myDataObject.SetData(DataFormats.Bitmap, true, pictureBox1.Image);
  337. Clipboard.SetDataObject(myDataObject, true);
  338. }
  339.  
  340. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  341. {
  342.  
  343. frmAbout frm = new frmAbout();
  344. frm.ShowDialog(this);
  345. frm.Dispose();
  346. }
  347.  
  348. private void button4_Click_2(object sender, EventArgs e)
  349. {
  350. try
  351. {
  352. pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
  353. pictureBox1.Refresh();
  354. }
  355. catch
  356. {
  357. //
  358. }
  359. }
  360.  
  361. private void button5_Click_2(object sender, EventArgs e)
  362. {
  363.  
  364. pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
  365. pictureBox1.Refresh();
  366. }
  367.  
  368. private void button6_Click(object sender, EventArgs e)
  369. {
  370. pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipXY);
  371.  
  372. pictureBox1.Refresh();
  373. }
  374.  
  375. private void button7_Click(object sender, EventArgs e)
  376. {
  377. pictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipXY);
  378. pictureBox1.Refresh();
  379. }
  380.  
  381. private void saveEditsToolStripMenuItem_Click(object sender, EventArgs e)
  382. {
  383. try
  384. {
  385. saveFileDialog10.Filter = "*.jpg|*.jpg|*.bmp|*.bmp|*.gif|*.gif";
  386.  
  387. saveFileDialog10.ShowDialog();
  388. if (saveFileDialog1.FileName != "")
  389. {
  390.  
  391. System.IO.FileStream fs =
  392. (System.IO.FileStream)saveFileDialog10.OpenFile();
  393.  
  394. switch (saveFileDialog10.FilterIndex)
  395. {
  396. case 1:
  397. this.pictureBox1.Image.Save(fs,
  398. System.Drawing.Imaging.ImageFormat.Jpeg);
  399. break;
  400.  
  401. case 2:
  402. this.pictureBox1.Image.Save(fs,
  403. System.Drawing.Imaging.ImageFormat.Bmp);
  404. break;
  405.  
  406. case 3:
  407. this.pictureBox1.Image.Save(fs,
  408. System.Drawing.Imaging.ImageFormat.Gif);
  409. break;
  410. }
  411.  
  412. fs.Close();
  413. }
  414. }
  415. catch { MessageBox.Show("there is no Pic selected please select a Pic first", "Dear " + System.Environment.UserDomainName); }
  416. }
  417.  
  418. private void hhToolStripMenuItem_Click(object sender, EventArgs e)
  419. {
  420.  
  421. saveFileDialog11.Filter = "*.ico|*.ico";
  422.  
  423.  
  424. saveFileDialog11.ShowDialog();
  425.  
  426.  
  427.  
  428. System.IO.FileStream fs =
  429. (System.IO.FileStream)saveFileDialog11.OpenFile();
  430.  
  431.  
  432.  
  433. this.pictureBox1.Image.Save(saveFileDialog11.FileName);
  434.  
  435.  
  436.  
  437. }
  438. }
  439. }

I want to be able to press a button after the bitmap,jpeg ect. has been loaded into the picturebox, and it spit it out as an icon. This works for the other formats. It doest work for this one, it says its an icon on it but u cant see the picture like you should be able to.


(The different color is where i think my problem is)
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC