C#: Preserving Bits Per Plane When Resizing Images?
Sep 27, 2010
I'm developing a service in which users can upload images and save them in a library. I want to preserve the original file (so people can upload high resolution images), but also make a copy of the image to use as a thumbnail.
The problem I have is that the thumbnail "weights" much more than the original file, proportionally. When I check the basic properties of each file (in XnView), I can see that the original files are for instance saved with 32 bits per Plane, whereas the source file will have, for instance, only 24 bits per plane.
What would be the correct way to make a copy of the original file while still using compression? This is an excerpt of the code:
private void ResizeImage(string originalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider, string directory)
{
System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(originalFile);
// Prevent using images internal thumbnail
[Code]....
View 2 Replies
Similar Messages:
Mar 18, 2010
I need to take an uploaded image, resize it, and save it to the database. Simple enough, except I don't have access to save any temp files to the server. I'm taking the image, resizing it as a Bitmap, and need to save it to a database field as the original image type (JPG for example). How can I get the FileBytes() like this, so I can save it to the database?Before I was using ImageUpload.FileBytes() but now that I'm resizing I'm dealing with Images and Bitmaps instead of FileUploads and can't seem find anything that will give me the bytes.
View 3 Replies
Aug 12, 2010
I'm building a Web application that will eventually contain a lot of images. These images will need to be displayed in different formats across the site. What would be the pros/cons of the two solutions:
Storing various versions of the picture when they are uploaded (e.g. thumb, small, medium, large, verylarge)
Resizing the image through the URL - e.g. /Content/Image/1?height=300
Edit:I had a really hard time accepting one answer over the other, so for anyone reading this q/a, take your time to read both answers because the accepted answer was selected by the flip of a coin :) They're both equally good.
View 2 Replies
Apr 20, 2010
I am trying to make some sort of map, where users can select a coordinate on it, and get certain information about it. (it's for a game). Is there anyway to do this in vb.net/asp.net?
View 5 Replies
Aug 24, 2010
I have a webpage where users can create a database record and select a file they want to upload to the database server. these files can be big, like 100mb.
I dont want the user to wait, so I want the file to be uploaded in the background. So that they can continue with doing other stuff while the file is being uploaded.
Is BITS the way to go for this? Or is that only for Fatclient development? Any good tuterials
?
If BITS is not the way to go, what are my options? An ajax call to a services with the filelocation?
View 2 Replies
Sep 29, 2010
i am writing a website that has a social networking element to it, and i want to display mutual friends of the person being viewed with the person that is viewing.
is it possible to search one database table and look for matching entries using 2 different usernames? if so how would i do it?
View 6 Replies
Mar 8, 2010
Our system is designed to deploy to regions with unreliable and/or insufficient network connections. We build our own fault tolerating data replication services that uses BITS.
Due to some security and maintenance requirements, we implemented our own ASP.NET file download service on the server side, instead of just letting IIS serving up the files. When BITS client makes an HTTP download request with the specified range of the file, our ASP.NET page pulls the demanded file segment into memory and serve that up as the HTTP response. That is the theory. ;) This theory fails in artificial lab scenarios but I would not let the system deploy in real life scenarios unless we can overcome that.
Lab scenario: I have BITS client and the IIS on the same developer machine, so practically I have enormous network "bandwidth" and BITS is intelligent enough to detect that. As BITS client discovers the unlimited bandwidth, it gets more and more "greedy". At each HTTP request, BITS wants to grasp greater and greater file ranges (we are talking about downloading CD iso files, videos), demanding 20-40MB inside a single HTTP request, a size that I am not comfortable to pull into memory on the server side as one go. I can overcome that simply by giving less than demanded. It is OK.
However, BITS gets really "confident" and "arrogant" demanding files WITHOUT specifying the download range, i.e., it wants the entire file in a single request, and this is where things go wrong. I do not know how to answer that response in the case of a 600MB file. If I just provide the starting 1MB range of the file, BITS client keeps sending HTTP requests for the same file without download range to continue, it hammers its point that it wants the entire file in one go. Since I am reluctant to provide the entire file, BITS gives up after several trials and reports error.
View 1 Replies
Dec 30, 2010
I got VS2010 and SQL Server 2008 R2 64bit installed on a Windows Server 2008 R2, I need to execute a SSIS package from ASP.NET. From the research most people uses DTS, but it seems DTS does not support for 64bit, does anyone have a way make it working without using DTS?
View 1 Replies
Jun 24, 2010
I want to read a message from SQL server and send it via email ,with its formatting maintained.
Sql server has the message stored into it via powerbuilder(different environment),When i send the email with HTML enabled all the formatting with which the message was saved is a lost
View 3 Replies
May 17, 2010
if the code below would achieve what I want, which is: Check if the query parameters 'return_path' and/or 'user_state' are present in the query string, and if so append them to the query string of the redirect URI. As I'm not a .NET dev and don't have a server to test this on, I was hoping someone could give me some feedback.
ArrayList vars = new ArrayList();
vars.Add("return_path");
vars.Add("user_state");[code].....
View 1 Replies
Sep 13, 2010
I've just updated my ASP.Net code from HttpContext.RewritePath(targetPath) to use the .Net 3.5 function: HttpContext.Server.TransferRequest(targetPath,true)
However, I now no longer have any of the custom HttpContext.Items that I added, before the transfer.
View 1 Replies
Aug 4, 2010
I' m using Reorder list sample for the first time. When it is bound with datasource, and reordered it is working fine. but unfortunately on postback to the server, i',m not getting the reordered items.
View 5 Replies
Feb 18, 2010
I have a web form with a repeater and an update panel with a ListView, the ListView contains a LinkButton, when I click the LinkButton a new window opens, when I click the Back Button I return to the form with the repeater but the ListView has disappered leaving a blank Update Panel.
how I can preserve viewstate and see the ListView when I click the BackButton.
View 2 Replies
Apr 7, 2010
I want to read data from excel while preserving format of the data.
If data is entered as below in the cell
"this is test sample data"
so my o/p should be
<p> this is test </p>
<p>sample data</p>
or something like that which preserves the data formatting.
View 4 Replies
Jun 25, 2010
I have an asp:TreeView in my MasterPage, which is loaded on demand from a database using some custom functions to fill the Tree. My tree will only ever be 4 levels deep (root -> 1st sublevel -> 2nd sublevel -> leaf nodes) What I want to achieve is preserving the expand/collapse state of this TreeView while navigating between different aspx pages, that all share the MasterPage holding my TreeView. I have been using the methods described in these resources:
[URL]
but I am still not getting the results I want... My TreeView markup in the MasterPage looks like this:
[Code]....
I am using a custom class to save and retrieve the state of the TreeView, the code is pasted below:
[Code]....
In my Page_Load on MasterPage I have:
[Code]....
where Reload() makes sure I'm loading the TreeView for the correct argument (based on a user selection)
And in TreeView_Unload I have:
[Code]....
With all this in place, my TreeView is behaving almost as I want it.. I can expand the root node, it will be populated and I can browse to a new content page and have the same treeview appear in the MasterPage (with same expanded root)... BUT if I try to expand any of the 1st sublevel nodes, I end up with a completely collapsed treeview instead. After some debugging I have come to the conclusion that the "NodeExpanded" event gets the ROOT NODE as event argument instead of the 1st sublevel node that I clicked. When the user changes the option that makes the TreeView re-populate with new data, I simply do a "HttpContext.Current.Session("TreeViewState") = Nothing" to reset my saved state.
If you need more info / code snippets, let me know and I will post it.. But I felt there was no reason to post my complete source, as I have multiple files with about 500 lines of code each (there's a lot happening on the MasterPage, other than the TreeView)
View 6 Replies
Oct 8, 2010
I've created a dynamic button from another control outside of the update Panel. The button is given an ID and such. When the button is click, a postback occurs and I've re-created this button during Page_Init, Page_PreLoad, and Page_Onload and NONE of them is preserving the value.
The only way for me to find the control was to look at the Page.request.form's allkeys and compare the string with a any text string that contains: Button. Because I ID'd teh button as: ButtonRow_0Col0. But the actual ID is null. However, when traversing through page.request.form, the allkeys shows that ID with no problem.
So how come the actual ID is lost after a partial postback yet, the page.request.form's allkeys can pull out its allkey's value??
View 4 Replies
Mar 26, 2014
Ok so I have two listboxes on my page one for users and another for cases. For some reason the users listbox preserves state, but the cases listbox doesn't.
They're both set EnableViewState= true
Code:
<asp:ListBox ID="ExistingUsers" runat="server" Width="45%" Height="189px"
CssClass="createdusers" ></asp:ListBox>
<asp:ListBox ID="ExistingCases" runat="server" Width="45%" Height="190px"
></asp:ListBox>
I tried setting them both to autopostback, but that didn't work. The users listbox would preserve the selected item, but make it the first viewable item in the list. The cases listbox still reset the selected item to the first.
My page load:
Code:
'....
If Not Page.IsPostBack Then
''Sort later.
Dim i As Integer = 10
For Each usr As String In AttRoleProvider.GetUsersInRole("Role1")
Me.ExistingUsers.Items.Add(usr)
[Code]......
View 4 Replies
Aug 7, 2013
PRESERVING STATE OF radiobuttonlist WHILE PAGING IN ASP.NET GRIDVIEW CONTROL.
View 1 Replies
Apr 5, 2012
I want to preserve state of Checkbox in Gridview, I do not have Checkall Checkbox. How to use below code
[URL] ....
This code because I do not have CheckboxAll check box... How to preserve Checkbox status while paging ?
View 1 Replies
Jan 7, 2011
For simplicity lets say that I have a web page that needs to display thumbnails of images. The images locations are stored in a database(the images are stored on Amazon S3). Is it possible to have my web server scale down the large image before it is delivered to the client? This way I don't have to store thumbnails of every image and the client can download a smaller file.
View 2 Replies
Mar 25, 2011
I am trying to add a user control into a div at runtime. I can add the control no probelem but it overwrites the previous control added.Basically, I am trying to add passengers to a travel system - the passenger details are in the user control and I don't know in advance how many there will be. I have an add new passenger button which should append the new user control into the div without overwriting the previous passenger. The code is c#/.net 4. I have tried to save the control data into viewstate and re add it with the new one but that also doesn't work. Here is a snippet of the code I'm using
foreach (Control uc in p_passengers.Controls) {
Passenger p = uc as Passenger;
if (p != null) {
p.SaveValues();
}
}
however, p.SaveAs() (just writes the control values into ViewState) is never hit.
View 1 Replies
Jan 12, 2010
I have a GridView and a DataList on the same page in a father/son relationship.I am trying to have the selected row on the GridView be in 'focus' on postback so if a person toward the bottom of the list is selected then the scroll position is maintained.I am trying to do the same with a DataList too.Heres my javascript.
[Code]....
and I have this around the GridView :
[Code]....
and this around the DataList:
[Code]....
The funny thing about this code is when I comment out the DataList portion, the GridView scroll postition works, when I comment out the GridView javascript portion the DataList scroll postion works.Is there a special way to make sure both of these can work or is it a javascript issue?
View 5 Replies
Aug 31, 2010
I have a question regarding the listview control paging and preserving the state of the items on page change.
I am using listview control and datapager control to achieve paging in the listview control.
I use the listview to display list of questions like with radiobutton list options as answers...
I am unable to preserve the selection of answers between the page changes..
for eg : I If select option1 for the question1 and move to a next page. and If I come back to previous page, the selection goes.
I tried using the view state...but could get this working..
View 2 Replies
May 7, 2015
I downloaded the code and when the gridview loads it works; however, when I select the next gridview index page, the gridview is blank. Don't know why it is not working like it should.
View 1 Replies
Sep 9, 2014
I found some code that resizes an uploaded image ( stream ) to a pre-determined size. Using this code, it works perfectly..
Code:
' make sure we have a file .
If FileUpload3.HasFile Then
Dim name As String = FileUpload3.PostedFile.FileName
Dim Justname As String = Path.GetFileName(name)
Dim length As Integer = FileUpload3.PostedFile.ContentLength
[Code] ....
What I'd like to do is move this code into a Class so I can call it from other pages, so I created a class and added this code...
Code:
Imports Microsoft.VisualBasic
Imports System.IO
Imports System
Imports System.Xml
Imports System.Xml.Xsl
[Code] ....
As you can see, I'm trying to pass in a stream and defined width, and I want it to pass back the image ( if the size if greater than what I expected.
I'm trying to call the class like so.
Code:
' make sure we have a file and that we have an ID to set it to.
If FileUpload3.HasFile Then
Dim name As String = FileUpload3.PostedFile.FileName
Dim Justname As String = Path.GetFileName(name)
Dim length As Integer = FileUpload3.PostedFile.ContentLength
[Code] ....
Don't worry about the cc.imgStr this is just the path to my class which is defined futher up.
The Error I get is "Value of type system.io.stream, cannot be converted to ' 1 dimensional array of byte' "...
View 1 Replies