|
-
Jan 11th, 2008, 01:24 PM
#1
Thread Starter
Addicted Member
-
Jan 11th, 2008, 09:31 PM
#2
Re: Problem with zooming on a picture
save 1 of the larger pictures from this page + use that instead.
a larger picture made larger will probably display properly.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 12th, 2008, 04:01 PM
#3
Thread Starter
Addicted Member
Re: Problem with zooming on a picture
 Originally Posted by .paul.
save 1 of the larger pictures from this page + use that instead.
a larger picture made larger will probably display properly.
Thank u Paul
Let me ask my Q another way:
I need to magnify B&W pictures in B&W mode, not in color mode. I want to make all the pictures in that picturebox 'Black & white". How is it possible?
Thanks
-
Jan 12th, 2008, 04:04 PM
#4
Frenzied Member
Re: Problem with zooming on a picture
I have an idea how to do this. I'll try writing up a function for you. Hold on.
-
Jan 12th, 2008, 05:05 PM
#5
Frenzied Member
Re: Problem with zooming on a picture
First of all, when using the small image in the PictureBox.Image property, and setting the SizeMode to StretchImage, the image shows up exactly how you wanted it.
Secondly, your original JPEG image has speckles on it. This is probably due to the fact that it lost formatting when you saved it as a JPEG. Perhaps you should try saving the original, perfectly formatted image in Photoshop to avoid formatting loss.
If the SizeMode property isn't working for you, which it should, I wrote up this function anyways to resize an image. Maybe it will work better for you.
vb.net Code:
Public Shared Function ResizeImage(ByVal sourcePath As String, ByRef newSize As Size)
Dim img As Image = Image.FromFile(sourcePath)
Dim imgNew As New Bitmap(newSize.Width, newSize.Height, Imaging.PixelFormat.Format1bppIndexed)
Dim graphics As Graphics = graphics.FromImage(imgNew)
graphics.DrawImage(img, 0, 0, imgNew.Width, imgNew.Height)
Return imgNew
End Function
vb.net Code:
PictureBox1.Image = ResizeImage("C:\Documents and Settings\Fromethius\Desktop\image.gif", New Size(104, 107))
If you cannot create a properly formatted image, you can always make an image black and white and then apply resizing, as that should work.
You can make an image black and white using a properly coded ColorMatrix which should look something like this:
vb.net Code:
Dim cm As New ColorMatrix(New Single()() {New Single() {0.5F, 0.5F, 0.5F, 0, 0}, New Single() {0.5F, 0.5F, 0.5F, 0, 0}, New Single() {0.5F, 0.5F, 0.5F, 0, 0}, New Single() {0, 0, 0, 1, 0, 0}, New Single() {0, 0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 0, 1}})
Then you can use the ImageAttributes class to create a Bitmap like this.
Also, you can try looking into the Graphics.InterpolationMode for proper resizing.
-
Jan 12th, 2008, 05:10 PM
#6
Re: Problem with zooming on a picture
fromethius, did you try that with a 4*4 image as the original?
i'm not sure what you mean with the colormatrix thing. how are you making the image b+w?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 12th, 2008, 05:14 PM
#7
Frenzied Member
Re: Problem with zooming on a picture
No, I didn't yet because she didn't post it. I only tried this one:
http://aycu23.webshots.com/image/400...2488927_rs.jpg
About the ColorMatrix: You can make an image monochrome by using a ColorMatrix and ImageAttributes.
-
Jan 12th, 2008, 05:15 PM
#8
Re: Problem with zooming on a picture
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 12th, 2008, 06:21 PM
#9
Frenzied Member
Re: Problem with zooming on a picture
Yea, sure. Here you go. I just wrote this up:
vb.net Code:
Imports System.Drawing.Imaging Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PictureBox1.Image = GetGreyscaledImage(New Bitmap("C:\Documents and Settings\Fromethius\My Documents\My Pictures\image.png")) End Sub Public Shared Function GetGreyscaledImage(ByRef setImage As Image) As Image Dim greyscaleBitmap As Bitmap = New Bitmap(setImage.Width, setImage.Height) Dim greyscaleGraphics As Graphics = Graphics.FromImage(greyscaleBitmap) Dim greyscaleColorMatrix As New ColorMatrix(New Single()() { _ New Single() {0.5F, 0.5F, 0.5F, 0, 0}, _ New Single() {0.5F, 0.5F, 0.5F, 0, 0}, _ New Single() {0.5F, 0.5F, 0.5F, 0, 0}, _ New Single() {0, 0, 0, 1, 0, 0}, _ New Single() {0, 0, 0, 0, 1, 0}, _ New Single() {0, 0, 0, 0, 0, 1}}) Dim greyscaleImageAttributes As New ImageAttributes() greyscaleImageAttributes.SetColorMatrix(greyscaleColorMatrix) greyscaleGraphics.DrawImage(setImage, New Rectangle(0, 0, setImage.Width, setImage.Height), 0, 0, setImage.Width, setImage.Height, GraphicsUnit.Pixel, greyscaleImageAttributes) Return greyscaleBitmap End Function End Class
-
Jan 12th, 2008, 06:47 PM
#10
Re: Problem with zooming on a picture
ok thanks that works.
i'd rate you but i haven't rated 10 people since last time....
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|