PC Review


Reply
Thread Tools Rate Thread

can i change the size of a file dynamically

 
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      26th Jan 2007
can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      26th Jan 2007
What file do you mean?


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> can i change the size of a file dynamically ?
> for example have 100 Kb and i want to decrease it to 20 Kb
> thanks
>



 
Reply With Quote
 
Michael D. Ober
Guest
Posts: n/a
 
      26th Jan 2007
System.IO.FileStream.SetLength()

Mike.

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What file do you mean?
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> can i change the size of a file dynamically ?
>> for example have 100 Kb and i want to decrease it to 20 Kb
>> thanks
>>

>
>



 
Reply With Quote
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      26th Jan 2007

Alexey Smirnov äæÔÊå ÇÓÊ:
> What file do you mean?
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > can i change the size of a file dynamically ?
> > for example have 100 Kb and i want to decrease it to 20 Kb
> > thanks
> >

oh sorry alexy i forgot
image file
jpg or gif
thanks for reply

 
Reply With Quote
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      26th Jan 2007

Michael D. Ober äæÔÊå ÇÓÊ:
> System.IO.FileStream.SetLength()
>
> Mike.
>
> "Alexey Smirnov" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > What file do you mean?
> >
> >
> > <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> can i change the size of a file dynamically ?
> >> for example have 100 Kb and i want to decrease it to 20 Kb
> >> thanks
> >>

> >
> >

thanks mike
is it for image file ?
i am a little amateur about image
can i change an image file size when it will shown by image control
may the main image file size have no change and only in image control
is decreased
thanks

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      27th Jan 2007
Do you mean you want to resize an image dynamically (make its width and
height smaller)?
Or you want to change a quality/resolution of your image (decrease the
number of colors)?

Look at this
http://www.google.com/search?hl=en&q...+image+asp.net



On Jan 26, 10:03 pm, "miladha...@gmail.com" <miladha...@gmail.com>
wrote:
> Michael D. Ober äæÔÊå ÇÓÊ:
>
>
>
> > System.IO.FileStream.SetLength()

>
> > Mike.

>
> > "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
> >news:(E-Mail Removed)...
> > > What file do you mean?

>
> > > <miladha...@gmail.com> wrote in message
> > >news:(E-Mail Removed)...
> > >> can i change the size of a file dynamically ?
> > >> for example have 100 Kb and i want to decrease it to 20 Kb
> > >> thanksthanks mike

> is it for image file ?
> i am a little amateur about image
> can i change an image file size when it will shown by image control
> may the main image file size have no change and only in image control
> is decreased
> thanks- Hide quoted text -- Show quoted text -


 
Reply With Quote
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      27th Jan 2007

Alexey Smirnov نوشته است:
> Do you mean you want to resize an image dynamically (make its width and
> height smaller)?
> Or you want to change a quality/resolution of your image (decrease the
> number of colors)?
>
> Look at this
> http://www.google.com/search?hl=en&q...+image+asp.net
>
>
>
> On Jan 26, 10:03 pm, "miladha...@gmail.com" <miladha...@gmail.com>
> wrote:
> > Michael D. Ober äæÔÊå ÇÓÊ:
> >
> >
> >
> > > System.IO.FileStream.SetLength()

> >
> > > Mike.

> >
> > > "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
> > >news:(E-Mail Removed)...
> > > > What file do you mean?

> >
> > > > <miladha...@gmail.com> wrote in message
> > > >news:(E-Mail Removed)...
> > > >> can i change the size of a file dynamically ?
> > > >> for example have 100 Kb and i want to decrease it to 20 Kb
> > > >> thanksthanks mike

> > is it for image file ?
> > i am a little amateur about image
> > can i change an image file size when it will shown by image control
> > may the main image file size have no change and only in image control
> > is decreased
> > thanks- Hide quoted text -- Show quoted text -

i want to change the quality
i can change the height and and width of it but the file size is same
100KB=100KB

may you help me please?
thanks

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      28th Jan 2007
> > > > > <miladha...@gmail.com> wrote in message
> > > > >news:(E-Mail Removed)...
> > > > >> can i change the size of a file dynamically ?
> > > > >> for example have 100 Kb and i want to decrease it to 20 Kb
> > > > >> thanksthanks mike
> > > is it for image file ?
> > > i am a little amateur about image
> > > can i change an image file size when it will shown by image control
> > > may the main image file size have no change and only in image control
> > > is decreased
> > > thanks- Hide quoted text -- Show quoted text -i want to change the quality

> i can change the height and and width of it but the file size is same
> 100KB=100KB


You should check EncoderParameters Class (System.Drawing.Imaging),
which you can use when you create a new image.

You need to create a new Bitmap from the original image and set all
parameters you need. There is no way to set the size of the file of
target Bitmap and you have to play with resolution and quality
settings.

Sample code (VB):

Dim SourceBitmap As Drawing.Bitmap = New Bitmap(imageSrc)
Dim TargetBitmap As Drawing.Bitmap = New Bitmap(imageHeight,
imageWidth)

' To set resolution 72 dpi

Const res As Single = 72
TargetBitmap.SetResolution(res, res)

Dim objGraphics As Drawing.Graphics = Graphics.FromImage(TargetBitmap)

Dim objEncoder As Imaging.EncoderParameters

objGraphics.CompositingQuality = Drawing2D.CompositingQuality.Default
objGraphics.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic

' Take a look MSDN for CompositingQuality and InterpolationMode -
there are many other settings

Dim recCompression As Rectangle = New Rectangle(0, 0, imageHeight,
imageWidth)
objGraphics.DrawImage(objSourceBitmap, recCompression)

objEncoder = New Imaging.EncoderParameters(2)

' Tell it to be "Encoder.Quality" with the desired iJPGQuality
objEncoder.Param(0) = New
Imaging.EncoderParameter(Imaging.Encoder.Quality, 85) ' 100 - quality
0..100
objEncoder.Param(1) = New
Imaging.EncoderParameter(Imaging.Encoder.Compression,
Imaging.EncoderValue.ColorTypeCMYK) ' 100 - quality 0..100

I would also recommend to look for more samples

http://www.google.com/search?hl=en&q...oderParameters

etc.

 
Reply With Quote
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      28th Jan 2007
oh my goodness
very good
i don't forget you my friend
i will go to test it
thanks alot alexey

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to dynamically change screen size by converting twips jsrogol Microsoft Access Forms 2 4th Oct 2009 06:00 AM
Dynamically change size of Array type and IEnumerable Jon Slaughter Microsoft C# .NET 3 3rd Apr 2008 09:33 PM
How do I change the size of cells dynamically in Excel? =?Utf-8?B?TGl0dGxlIEVhZ2xl?= Microsoft Excel Worksheet Functions 1 4th Oct 2007 01:09 AM
Function To Dynamically Display File Size =?Utf-8?B?TURX?= Microsoft Excel Worksheet Functions 1 16th Feb 2006 09:45 PM
How to change font size dynamically? VB Programmer Microsoft VB .NET 5 5th Sep 2003 04:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:16 PM.