daveydave400 Posted October 27, 2005 Posted October 27, 2005 OK I have a program and all that really matters is that I am displaying a picture on a picturebox. When I display a 800 by 600 picture on a stretched picturebox it has horrible resolution it gets all pixelated and blurry and when it is displayed in normal mode it is like 5 pixels wide. Is there something I am forgetting or maybe I am doing wrong, if you have answers please tell. Thanks Quote
MXever7 Posted October 27, 2005 Posted October 27, 2005 As I understand your problem: when you "stretch" the image, the quality is bad. What you need to do is draw a new image "stretched" to the appropriate size. The link below leads to a nice tutorial on making high quality thumbs. High Quality Thumbs -MXever7 Quote
mskeel Posted October 27, 2005 Posted October 27, 2005 (edited) What is the size and resolution of the actual picture? If your image is 5 pixels wide and you stretch it you will lose detail, that's just the way it is. Edit: I just saw MXever7's post, I think we were writing at the same time. That will work if you going from big to small, but I don't htink it work going small to big. Edited October 27, 2005 by mskeel Quote
daveydave400 Posted October 27, 2005 Author Posted October 27, 2005 (edited) A Little More Detailed My own solution: If I change the imagelist size of the images to 256, 192 which is the correct ratio i believe for 800 by 600 because the max size is 256, it makes the images much more visible, there is very slight blurr. So I changed the size in the imagelist removed and then added the images in the imagelist again and it was "basically" fixed. If anyone has a way using this same method to make the pictures even more acceptable please tell. My 2nd solution: Upon finding out my previous solution I found that if I add a image to the picturebox through the picturebox's image properties it has a lot better resolution so I will just make it load the images straight from the file instead of from the imagelist, Thanks anyway but I guess I solved it. If you guys know anyway to load images from the same file as the .exe file is located in I need help with that. This program is for a small cabinet business or something(got it through programming teacher), so he needs to put the program on a disc and distribute it to his customers or potential customers and autorun the program so then they choose a room, style, and look through the images for that style. I have all of that figured out but as many of you know not all disc drives have the same directory letter so is it possible to tell the program to get the images from the directory that it is in. Thanks. Edited October 27, 2005 by daveydave400 Quote
mskeel Posted October 27, 2005 Posted October 27, 2005 Here's a trick that might help. Put the image in your project and set it's Build Action to be an embedded resource. Use this code to load the picture at run time: '' put this line somewhere like your form load or a button click when you want the image to show up: ' ' picturebox1.Image = GetEmbeddedIcon("exact_name_of_image.extension") ' ' 'This is the Method that you will call when you set the Image Property as shown on the line above: Private Function GetEmbeddedIcon(ByVal imageName As String) As Bitmap Try Return New Bitmap(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("Fully.Qualified.Namespace." + imageName)) Catch ex As Exception Throw New InvalidImageException(imageName, ex) ''I created a custom exception but you can just as easily use a regular Exception or don't catch and rethrow like I did here. End Try End Function The big trick here is that the argument, imageName, must be spelled EXACTLY as it is in your project, including the extension and namespace. This means that if you add a file called super.gif and your project namespace is Ultra.Wicked, then imageName = "Ultra.Wicked.Super.gif". Capitalization matters here. The fuzzy problem is really annoying but this should get rid of it. Hope this helps. Quote
daveydave400 Posted October 27, 2005 Author Posted October 27, 2005 Right Well If you look at my last edited message you will see that I have basically solved the resolution problem and I need help on the whole directory thing. I dont know anything about try and throw commands what you just wrote I dont even understand, remember I am a beginner. Quote
*Experts* DiverDan Posted October 27, 2005 *Experts* Posted October 27, 2005 You can also store your pictures in the same directory as your application during the installation onto the user's computer. Then collect the pictures from the application's startup path via PictureBox1.Image = Image.FromFile(Application.StartupPath & "\yourFileNameHere.ext"). Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
daveydave400 Posted October 27, 2005 Author Posted October 27, 2005 (edited) Thanks Right before I read this again I found out the curdir thing on some website so instead of doing the whole application.startuppath I just declared a variable as the path: Dim exedir As String exedir = CurDir() If ComboBox3.SelectedItem = ("K1") Then PictureBox1.Image = System.Drawing.Bitmap.FromFile(exedir & "\IMG_0563F.jpg") End If Another Question: Does anyone know how on program load I can get the name of each folder in a directory or specifically the exedir, and then display each folders name as a line in a combobox and after doing that it takes every file in each folder that is a .jpg and for each .jpg file it creates a line in another combobox that is coded so for each file it would be like K1, K2, K3, etc. and if they picked another folder it would be something like B1, B2, B3, etc. and I'm sure I wont easily find this on the internet cuz i have been looking for quite a while. Edited October 27, 2005 by daveydave400 Quote
mskeel Posted October 27, 2005 Posted October 27, 2005 (edited) Well If you look at my last edited message you will see that I have basically solved the resolution problem and I need help on the whole directory thing. daveydave400, I'm not sure how to reply to that. Take a look at the time stamps, bucko. I posted at 12:19, your last edit was at 12:23, four minutes AFTER I posted my response. I understand that slinging code can be frusterating at times, but I would appreciate it if you wouldn't take your frustration out on the help. Unfortunately, I can't read posts before you post them. Do everyone a favor and post a new message next time instread of completely revamping your old post. I beleive the message before was a plea for help or something like that to which I responded. This is a learning and information forum. If you don't understand something, then please ask. Throwing your hands up and saying "I don't understand! Just give me code!" doesn't help anyone, esspecially not yourself. You have to be willing to learn something and help yourself if you expect to be helped. Now then, do you need help with something else or has your problem been resolved? edit: I just saw your new edit which you must have posted while I was writing. Check out the System.IO.Directory namespace. Edited October 27, 2005 by mskeel Quote
daveydave400 Posted October 27, 2005 Author Posted October 27, 2005 (edited) I don't know how the forum system works, sorry Whoa!, sorry man didn't mean to be disrespectful or anything I was just trying to tell you that I was editing my message cuz at the time it was the newest message and when I had thought it all over and figured out how I wanted to say everything you had already posted your thing before I finished editing mine, sorry I respect the help and I respect everyone that is giving it but yeah if you guys dont want to help anymore then please dont I can now see that I am basically asking you guys to finish my program for me and I am not trying to do that, it's just that I have tried to google a lot of the help and none of its close enough to what I need to understand what I need, but I am trying to learn a lot of things and most of them don't work and I am only a beginner and do not know how to do a lot of things in VB .net and obviously if i can't understand the code you guys try to help me with I need a few more classes but yeah I understand where your coming from didnt mean anything by it and you guys dont have to help anymore I'll just figure it out myself somehow. Edit: On your edit you told me to check out the msdn thing and I tried that but when I did it doesnt have "Directory" as anything it says that its not declared so maybe my version is different but yeah if anyone knows y or if that is the reason y please reply. Edited October 27, 2005 by daveydave400 Quote
mskeel Posted October 27, 2005 Posted October 27, 2005 It's cool man, just a misunderstanding. We are all trying to talk(post) at the same time and it is just getting confusing. I tend to be a little over dramatic at times anyway, sorry. Try this. Make a new windows forms project. At the top of the project put this line:Imports System.IO Put a single button on the form and put this code in the button click handler: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Console.WriteLine("*************") For Each filename As String In Directory.GetFiles(CurDir) Console.WriteLine(filename) Next Console.WriteLine("*************") End SubRun the program and hit the button. You should see something like:************* C:\Documents and Settings\YourUserName\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\bin\WindowsApplication3.exe C:\Documents and Settings\YourUserName\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\bin\WindowsApplication3.pdb ************* in the output window in VS. Only some of the .Net Framework is going to be avialable to you by default. There're tons of great tools that you must explicity tell the compiler you want to use. Otherwise the compiler won't know what you are talking about. The System.IO namespace happens to be one of them. My experience is that Google is great for obscure or strange information or code. The MSDN is the best place to start when you are trying to do just about anything. You probably have a full copy installed with Visual Studio. If not, the web is the exact same thing. Once you become more familiar with how to read the documentation and how to search it, things will become a lot easier. Quote
daveydave400 Posted October 27, 2005 Author Posted October 27, 2005 (edited) Alright Well I did all of that and I get most of it but where is it suppose to display the message or the text or w/e. Edit: Nevermind I found it Thanks I think I can figure it out or at least try to figure it out Edited October 27, 2005 by daveydave400 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.