473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2337
What file do you mean?
<mi********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.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.FileS tream.SetLength ()

Mike.

"Alexey Smirnov" <al************ @gmail.comwrote in message
news:OD******** ******@TK2MSFTN GP05.phx.gbl...
What file do you mean?
<mi********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.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********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.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.FileS tream.SetLength ()

Mike.

"Alexey Smirnov" <al************ @gmail.comwrote in message
news:OD******** ******@TK2MSFTN GP05.phx.gbl...
What file do you mean?
<mi********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.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...@gma il.com" <miladha...@gma il.com>
wrote:
Michael D. Ober :
System.IO.FileS tream.SetLength ()
Mike.
"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message
news:OD******** ******@TK2MSFTN GP05.phx.gbl...
What file do you mean?
<miladha...@gma il.comwrote in message
>news:11******* **************@ k78g2000cwa.goo glegroups.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...@gma il.com" <miladha...@gma il.com>
wrote:
Michael D. Ober äæÔÊå ÇÓÊ:
System.IO.FileS tream.SetLength ()
Mike.
"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message
>news:OD******* *******@TK2MSFT NGP05.phx.gbl.. .
What file do you mean?
<miladha...@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.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...@gma il.comwrote in message
>news:11******* **************@ k78g2000cwa.goo glegroups.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 EncoderParamete rs 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(imageHei ght,
imageWidth)

' To set resolution 72 dpi

Const res As Single = 72
TargetBitmap.Se tResolution(res , res)

Dim objGraphics As Drawing.Graphic s = Graphics.FromIm age(TargetBitma p)

Dim objEncoder As Imaging.Encoder Parameters

objGraphics.Com positingQuality = Drawing2D.Compo sitingQuality.D efault
objGraphics.Int erpolationMode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c

' Take a look MSDN for CompositingQual ity and InterpolationMo de -
there are many other settings

Dim recCompression As Rectangle = New Rectangle(0, 0, imageHeight,
imageWidth)
objGraphics.Dra wImage(objSourc eBitmap, recCompression)

objEncoder = New Imaging.Encoder Parameters(2)

' Tell it to be "Encoder.Qualit y" with the desired iJPGQuality
objEncoder.Para m(0) = New
Imaging.Encoder Parameter(Imagi ng.Encoder.Qual ity, 85) ' 100 - quality
0..100
objEncoder.Para m(1) = New
Imaging.Encoder Parameter(Imagi ng.Encoder.Comp ression,
Imaging.Encoder Value.ColorType CMYK) ' 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
5573
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 of my HTML (from JavaScript). But can`t dynamically refresh SVG, becouse SVG support only ECMAScript This old ECMAScript specification do not...
14
8495
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 integers in the file... How should I go about creating the array int array dynamically ? the file is
5
5585
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
57225
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 is Write-Protected. There is only a Get-Method and no Set. Plz Help
5
130240
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
13018
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 STATIC, i can have whatever size of data i want. but if the data (xml or text) is generated dynamically using php, then there seems to be a size...
0
2049
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 dynamically change the flat file location so that on a pre-defined condition (date changes, file memory size exceeded), a new file is created and logging...
3
3833
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 user change font-size dynamically visited link's font-size will be change. i use dropdown list for font-size values . there are 24 links on the...
0
7704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7931
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7985
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6298
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5234
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3659
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1230
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
959
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.