Results 1 to 16 of 16

Thread: Resizing an image without having it look ****...?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88

    Smile

    Hey, I've been trying to make some sort of thumbnail viewer, but all the thumbs look like **** when they are reduced in size? Is there a way to make them look better?? I mean like, when you resize a picture in PaintShop Pro and make it small, it still looks good.
    Help is appreciated and rewarded with beers where appropriate, hihi

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    there's a bilinear resizing sample at http://www.ur.co.nz/

    but be prepared, it's slow. I wouldn't care if the thumbnails were resized the way paint shop pro resize them in the browser, which can be done with ie paintpicture, without much performance

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    "I wouldn't care if the thumbnails were resized the way paint shop pro resize them in the browser, which can be done with ie paintpicture, without much performance"

    Didn't really understand what you meant by this...?

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I'll take a labbatt....

    For / 2 thumbnails (20x20 - 10x10), average out each group of four pixels and plot that one pixel on the first one. Like kedaman said, these processes are slow.

    BTW. kedaman, your avatar was better non-existant. This one scares me.... :0
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Oh never mind, I just noticed what it was... I thought it was a picture of you warped, never mind...

    Silly me...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Hmmm.... the VB bilinear filter thingy didn't work.... it just warped whatever picture I put in? Weird... I probably did something wrong... but I don't think so.
    It seems to cut the picture in 2 part, showing one part to the left and the other part to the right... don't think I really understand why.

    Well, if you have ever used ACDSee they resize your picture in a preview image and that looks amazing even when it's really small. Do they use a routine like the one you gave me kedman? Or should I be looking for something different

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well it's a picture of me

    i suggest paintpicture again, and yep, the browser in psp doesn't do any bilinear resizing or anything close to that.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Could you give me some sort of example of using paintpicture to resize an image so it won't look ****ty when it gets like 70x70 or somethign similar?

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    sure

    Code:
    With Picture2
        Picture1.PaintPicture Picture2.Picture, 0, 0, 70, 70, 0, 0, .ScaleWidth, .ScaleHeight, vbSrcCopy
    End With

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88

    Talking

    Ah.... I guess what my realy question should have been was how to make the thumbs look smooth Well, I am resizing some gifs and some jpgs, the gifs looks like **** the jpgs are mostly ok. Probably since the gifs only contain 256 colors whereas the jpgs have millions of colors? So could you help me in any way making my thumbs for the gif files smoooth :=) ??

    Thanks for all the help so far

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well if you don't care how long it takes, go check out the link to unlimited realities i posted, there's a lot of other handy stuff out there too

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Well, I do care how long it takes, but I'll check out the link for more info, thanks.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Ok, I got the blurring/resizing part to work quite well, but there are a couple of things I don't understand. First of all this :

    The blurring seems to work poorly on very large images (bigger than 450 pixels in width) so I thought I'd resize them down to about 300 pixel in width and THEN blur them. But what happens is when I use paintpicture and then try to run the blur code I get to something the code can't handle... this part :

    Code:
    If bmp.bmBitsPixel <> 24 Then
        MsgBox " 24-bit bitmaps only", vbCritical
        Exit Sub
    End If
    When I use paintpicture the picture1.picture seems to not be a 24bit BMP anymore? Why is that and is there a say I can make it be a 24bit BMP? Here is the part of the code I use to resize the picture. If there is a better way to do it please tell

    Code:
    NewPicHeight = ThumbnailHeight
    NewPicWidth = Picture1.Width \ (Picture1.Height \ ThumbnailHeight)
    Picture2.Height = NewPicHeight
    Picture2.Width = NewPicWidth
    Picture2.PaintPicture Picture1.Picture, 0, 0, NewPicWidth, NewPicHeight
    Picture2.Picture = Picture2.Image
    
    c.CreateFromPicture Picture2.Picture
    Everything works really well, except for images larger than 450 pixels in width and larger than 450 pixels in height also, so any ideas as what to do?

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    thats somewhat weird, i haven't tried out the bigger images. About the 24 bit thing, if you paint picture to another picturebox, the image will probably gain the same properties as the picture, so if you have a non24 bit image, like a gif as picture, the image will turn out 8 bit too. This also might be the problem why your gif's looks crap when you used paintpicture earlier. Try it out before you go further.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Well, I've tried lots of stuff now, but no luck. Still get the message about the picture being a non24bit BMP... I'm using this code to intercept pictures larger than 450 pixels :

    Code:
    If Picture1.Width > (450 * 15.5) Then
    NewPicWidth = (450 * 15.5)
    NewPicHeight = Pic1Height \ (Pic1Width \ (450 * 15.5))
    Pictbuf.Height = NewPicHeight
    Pictbuf.Width = NewPicWidth
    Pictbuf.PaintPicture Picture1.Picture, 0, 0, NewPicWidth, NewPicHeight, , , , , vbSrcCopy
    Pictbuf.Picture = Pictbuf.Image
    Picture1.Picture = Pictbuf.Picture
    Picture1.Height = NewPicHeight
    Picture1.Width = NewPicWidth
    
    '****** BLURING *********
    DoImagePro "Blur"
    Picture1.Refresh
    '************************
    The DoIamgePro function takes the pictbuf as a source and the picture1 as destionation and blurs it. But when I resize my pics like this, I get that damn error... any more ideas? Am I doing something wrong when I resize the picture so that it is no longer 24bit?? Oh and I am using a .jpg picture (24bit) with a size of 1100x1200 so that's not the problem. The blur works fine when I remove the resize code, but since the picture is bigger than 450 in width the colors gets ****ed up...
    - zen

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Norway
    Posts
    88
    Well, I found a solution to my problem, kind of.... I found an example program that could blur the images as I wanted using something called DIB Sections and cDIBsection. Well, it looked really advanced so I'll see what I get out of it. If anyone could help me out with some pointers and tips on DIB Sections I would greatly appreciate it!!

    If anyone else needs help with these kinds of things, there's a lot of stuff covered here. A bit advanced though...
    http://www.vbaccelerator.com/codelib/gfx/imgproc2.htm
    - zen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width