• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

Stretch and Transparent Picturebox

I  have a public game that’s been out for 3 years now.
I have found that my program is not compatible with Windows Vista because there are 3 OCX files that do not register in vista. (assuming 16 bit versions).

I have managed to find 32 bit replacements for 2/3.
The one I have spent 5 days solid trying to find a replacement for is Transparentpicture.ocx.
The reason I cant find a replacement is because I need it to have 2 special features.

Stretching pictures larger or smaller and Transparent background ability at the same time

I have not been able to find a replacement ActiveX control so far.
I have found some that do either 1 or the other but not both at the same time.
i cannot use the Image control because my app uses Activeskin and image controls dont show up when skinned.
I have managed to find the code to stretch a picturebox control.

 So i have to find a way to have a transparent color in a picturebox or find a replacement ActiveX control that does both.


Win98/ME/2000/XP/Vista (32bit)
Visual Basic 6
0
kcmagicdata
Asked:
kcmagicdata
  • 3
  • 2
1 Solution
 
danaseamanCommented:
Following code supports most popular image formats, transparency, stretching, and rotation.
Also supports XP 32-bit images:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=67466&lngWId=1

It is not coded as an OCX but that would not be hard to implement or you could render to a Vb PictureBox.


0
 
kcmagicdataAuthor Commented:
Ive seen that code before and it is very in depth but it does not do the actual transparent background on a JPG it does tranparency like glass. And besides it would take me days to understand all the routines and code.

I have JPG images only that i want to make white or red backgrounds dissapear.
0
 
danaseamanCommented:
First time I've heard of JPG with transparency. The glass effect your are referring to is the "Opaque" property which can be applied to any image type using the above code independent of Transparency.

See the following link:

Subject: [12] Can I make a transparent JPEG?

No.  JPEG does not support transparency and is not likely to do so any time
soon.  It turns out that adding transparency to JPEG would not be a simple
task; read on if you want the gory details.

http://www.faqs.org/faqs/jpeg-faq/part1/

I would suggest you convert to PNG but what appears as solid red or white on a JPG is usually in fact a range of colors close to pure red or white.

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
kcmagicdataAuthor Commented:
Im sorry but there might be a bit of confusion here.
I dont want to do Transparency. I dont want the image to be "see through" like glass.
I want to be able to have a image preloaded such as a JPG or BMP and have a certain color that is a background in the picture not show up.

Here is an example of what i mean using the mentioned Transparentpicture.ocx in XP.

Here is what the actual image looks like

www.kaisergame.com/temp/100.bmp

and here is how it is suppose to look after the background of white has been removed.

http://www.kaisergame.com/Home/picture003.jpg

Not sure if those will come through as links?

My program has preloaded images that are from BMP and do not need to be stretched but do need to have the white background taken out. But a user also gets to load their own JPG files that will not need a transparent background but will need to be stretched to fit the size of the control. Because this is done in the same picturebox it has to have the ability to do both.






0
 
kcmagicdataAuthor Commented:
I managed to solve my own problem with a lot of searching and trying different code.

I found some excellent code that resizes the image in a Picturebox perfectly. Even when shrinking a JPG

        With Picture1
        .AutoRedraw = True
        .PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, ScaleX(.Picture.Width, vbHimetric, vbTwips), ScaleY(.Picture.Height, vbHimetric, vbTwips)
        .Picture = .Image
        Set Picture1.Picture = .Image
        End With

I also found an open source control that does transparent images very well. So i modified the control to have a stretch property and compiled it. If anyone wants to try it or see how well it works here is a link

www.kaisergame.com/temp/Transpic.ocx

Although it does not have an Auto Size property. So stretching doesnt resize the image control. Only because my application has predefined image sizes and didnt need that feature.


0
 
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now