473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

can i change the size of a file dynamically

can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks

Jan 26 '07 #1
8 2320
What file do you mean?
<mi********@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks

Jan 26 '07 #2
System.IO.FileStream.SetLength()

Mike.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:OD**************@TK2MSFTNGP05.phx.gbl...
What file do you mean?
<mi********@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
>can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks


Jan 26 '07 #3

Alexey Smirnov äæÔÊå ÇÓÊ:
What file do you mean?
<mi********@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
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

Jan 26 '07 #4

Michael D. Ober äæÔÊå ÇÓÊ:
System.IO.FileStream.SetLength()

Mike.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:OD**************@TK2MSFTNGP05.phx.gbl...
What file do you mean?
<mi********@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
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

Jan 26 '07 #5
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.comwrote in message
news:OD**************@TK2MSFTNGP05.phx.gbl...
What file do you mean?
<miladha...@gmail.comwrote in message
>news:11*********************@k78g2000cwa.googlegr oups.com...
>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 -
Jan 27 '07 #6

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.comwrote in message
>news:OD**************@TK2MSFTNGP05.phx.gbl...
What file do you mean?
<miladha...@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
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

Jan 27 '07 #7
<miladha...@gmail.comwrote in message
>news:11*********************@k78g2000cwa.googlegr oups.com...
>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.Compressi on,
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.

Jan 28 '07 #8
oh my goodness
very good
i don't forget you my friend
i will go to test it
thanks alot alexey

Jan 28 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Roman Gordin | last post by:
Hi, I use SVG for web-GUI, but found some serious restrictions 8-( When I use HTML (dynamically generated from .php), I may use HTTPRequest object to provide dynamically regeneration some part...
14
by: Sameer | last post by:
Hello, i wish to read a file of int and store into an array dynamically... the size of memory allocated finally, should just be sufficeient to store n integers. I do not know the number of...
5
by: nmtoan | last post by:
Hi, I could not find any answer to this simple question of mine. Suppose I have to write a program, the main parts of it are as follows: #include <blahblah.h> struct {
2
by: Bjoern | last post by:
Hi all, how can i change the Font Size of the Text in my Label. I will change it dynamic in the code. I tryed: int number = 11; label1.Font.Size = number; But this is not possible because Size...
5
by: VB Programmer | last post by:
How can I change the font size of a text box dynamically? I tried this but it didn't work. It said 'Size is Read-Only'. Any other ways around this? Here's the code: txtDisplay.Font.Size = 10
27
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
0
by: james.dixon | last post by:
Hi I have been having a bit of a look at the Microsoft Logging Application Block (using .NET 1.1). I found it easy to get going, but now have struck a bit of a brick wall. I want to...
3
by: reyo | last post by:
Hi, i design a dynamic web page.infact it will be a css generator. i have a question about visited link. i want to change color,font-size,font-weight etc. of a link when it is visited. when a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.