Bitmap file size
-
Hi all, Is there a way for checking the file size of a Bitmap without saving it to disk (using C#)? Thanks in advance, Danny
-
Hi all, Is there a way for checking the file size of a Bitmap without saving it to disk (using C#)? Thanks in advance, Danny
Wouldn't using a Temp File be more cleaner approach?
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson -
Wouldn't using a Temp File be more cleaner approach?
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis LevinsonVasudevan Deepak K wrote:
Wouldn't using a Temp File be more cleaner approach?
Thanks for you quick response. Yes it would, BUT, I'm trying to limit a Bitmap to a certain file size, say 50kb, so my solution was to loop through the bitmap's dimmensions, while each iteration is scaling the bitmap down. Now, inside this loop, using IO-write to the disk would be pretty slow... Any other idea? Danny
-
Vasudevan Deepak K wrote:
Wouldn't using a Temp File be more cleaner approach?
Thanks for you quick response. Yes it would, BUT, I'm trying to limit a Bitmap to a certain file size, say 50kb, so my solution was to loop through the bitmap's dimmensions, while each iteration is scaling the bitmap down. Now, inside this loop, using IO-write to the disk would be pretty slow... Any other idea? Danny
Hi, some suggestions: 1. you could save in a memory stream and get its size 2. you could do a binary search, example: if original width is 128 try 64; if too small, try (128+64)/2 = 96, else try (0+64)/2=32; repeat until you reach the optimal size. 3. the file size depends on the image format; some use compression, some don't. for the ones that don't, the size is proportional to width*height; for those that use compression, this is also true to some extent. 4. when scaling down the size, for best quality I suggest you always restart from the original image. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Sorry for any delays in replying, I currently don't always get e-mail notifications.
-
Hi, some suggestions: 1. you could save in a memory stream and get its size 2. you could do a binary search, example: if original width is 128 try 64; if too small, try (128+64)/2 = 96, else try (0+64)/2=32; repeat until you reach the optimal size. 3. the file size depends on the image format; some use compression, some don't. for the ones that don't, the size is proportional to width*height; for those that use compression, this is also true to some extent. 4. when scaling down the size, for best quality I suggest you always restart from the original image. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Sorry for any delays in replying, I currently don't always get e-mail notifications.
Hey Luc, I figured I can use a memory stream, that was my first try, before posting in this forum, but now I got it to work, I didn't understand the use of the ImageFormat, and now I do. #4 is a great idea, and I've implemented it. Thanks man. Danny
-
Hey Luc, I figured I can use a memory stream, that was my first try, before posting in this forum, but now I got it to work, I didn't understand the use of the ImageFormat, and now I do. #4 is a great idea, and I've implemented it. Thanks man. Danny
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
Sorry for any delays in replying, I currently don't always get e-mail notifications.