Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. save aimage from the form in .jpeg format

save aimage from the form in .jpeg format

Scheduled Pinned Locked Moved C#
graphicshelpmobile
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dhol
    wrote on last edited by
    #1

    Hi Using Microsoft.ink...I have to draw a image in the form and save that image in .jpeg format.....So i haveto install Microsoft Tablet pc..... so finally I installed ... and i did a program with 2 buttons in the form namely SAVE and EXIT...... so now when i run this program..i can able to draw a image of my own in the form..now when i click save button...i should be able to save the image in .jpeg format.. BUT I couldnt save.. when i click the SAVE button..and give a name for the image .... an error is shown... ERROR MESSAGE: System.NullReferenceException: Object reference not set to an instance of an object. at InkImage.Form1.button2_Click(Object sender, EventArgs e) in d:\inkimage\form1.cs:line 144.. ie, error in the last line of this program [ DrawArea.Save( sfd.FileName, format );] using System; using System.Drawing; using System.Drawing.Imaging; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Microsoft.Ink; using System.IO; namespace InkImage { public class Form1 : System.Windows.Forms.Form { // Declare the Ink Collector object private InkCollector myInkCollector; private const float ThinInkWidth = 50; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private Bitmap DrawArea;// make a persistent drawing area private void Form1_Load(object sender, System.EventArgs e) { // Create a new ink collector and assign it to this form's window myInkCollector = new InkCollector(this.Handle); // Set the pen width to be a width myInkCollector.DefaultDrawingAttributes.Width = ThinInkWidth; // Turn the ink collector on myInkCollector.Enabled = true; } //EXIT BUTTON private void button1_Click(object sender, System.EventArgs e) { myInkCollector.Enabled = false; this.Dispose(); } //SAVE BUTTON private void button2_Click(object sender, System.EventArgs e) { ImageFormat format = ImageFormat.Jpeg; SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JPEG Files(*.jpg)|*.jpg"; if (sfd.ShowDialog() == DialogResult.OK) { // now save the image in the DrawArea DrawArea.Save( sfd.FileName, format ); } } } } please help me to get the solution...... D h o l

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups