Hello everyone, i'm fresh new here, and i already have a question regarding...well, C#.
I've made a Forms Application in which the user submits an image (bmp,png,jpg or gif), and the image suffers some byte-level modifications (obviously, i'm using the LockBits() method).
Now, after the modifications are done, the user should be able to save the image in its original format (only the least important bits of the image get modified, so the image looks pretty much like the original).
I've developed a static class called ImageTextEncoder which has a public static member ImageTextEncoder.Image, which holds the submitted bitmap.
When i call ImageTextEncoder.Image.Save(Filename,Format) (if initially the image was a Jpeg, i will save it as a jpeg, same for png, gif, etc. ), and i upload the image back, visibly it suffered nothing, but its size gets modified (example: a 700 kb JPG got down to 140 kb), AND at byte level things are altered.
IS there a way i can save the image WITHOUT losing ANYTHING ( size, byte information) . (as a note, i need a solution asap, it's been bugging my application for some days now)
Thank you very much !
Recommended Answers
Jump to Postif the image is a different size, its probably the compression level. when you save your bitmap, if you save it as a jpeg file, you can alter its compression methods, changing its filesize, if you just call save, it uses the default. which might be different from the source …
Jump to PostI ment size as in file size not dimensions. sorry.
// We will store the correct image codec in this object ImageCodecInfo iciJpegCodec = null; // This will specify the image quality to the encoder EncoderParameter epQuality = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (int)80);//set quality here // Get all image …
Jump to PostWell the only reason it worked was because it wasn't really a JPG at all. See if you can disable the compression for JPEG so it doesn't modify the file's contents. Beyond that i'm not sure off hand, this is getting very file-format specific.
Jump to Postyour extention was jpg but the image was NOT a jpeg. extensions mean nothing. Listen.
1. If you want to preserve your changes you cannot compress it, because compression codecs change those values.
2. Saving as a BMP is uncompressed, So it will work, but the file will …
Jump to Postyou could in theory take your image and load it in as a byte array, not as an image, sift through the bytes and find the start of the image data, then apply them there, but idk what the results would be. but other than that. there isn't sorry.
All 26 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.