Solved

Stretch and Transparent Picturebox

Posted on 2007-03-19
8
437 Views
Last Modified: 2008-01-09
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
Comment
Question by:kcmagicdata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 22

Expert Comment

by:danaseaman
ID: 18753519
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
 

Author Comment

by:kcmagicdata
ID: 18753722
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
 
LVL 22

Expert Comment

by:danaseaman
ID: 18753789
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:kcmagicdata
ID: 18753897
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
 

Author Comment

by:kcmagicdata
ID: 18762063
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
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19159157
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Configuring Remote Assistance for use with SCCM
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question