-
Nov 8th, 2011, 07:41 AM
#281
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Well... in my photo software program there is only 1 setting and it's called transparency, and I never saw a program with "both" feature, so I'm guessing it's 2 way of talking of the same thing but with different effect in mind...
P.S. If you find a bug, especially one that annoys you, don't wait a month. I'm very receptive to bug reports
I Know you're very receptive to bug report, I just hate forum. I loved forum the way back in the '90 because they remembered exactly wich post you didn't read.... forum today don't do that and you're always trying to get where you where last time and it's time consuming for the least to say...
and I got very limited time
I'm surprised though that when I mentionned that bug you didn't answer me to check if I had the latest version. I mean, it make sense to me that if you already fixed the bug, you knew about it... unless it was a logic bug that you fixed and you never saw it in action...
in any case, as always, thanks for your GREEEEEEEAT product and continue your good work!
I have some product too (not related to graphic though) on Vb6 but I never posted them because I thought I was the only one still programing on Vb6... maybe I shall do like you ... but I'm affraid I would not have as many time as you for the bug report (and documentation) ...
take care.
-
Nov 8th, 2011, 09:18 AM
#282
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Originally Posted by VbNetMatrix
Well... in my photo software program there is only 1 setting and it's called transparency, and I never saw a program with "both" feature, so I'm guessing it's 2 way of talking of the same thing but with different effect in mind...
Agreed. Even in my code I use both terminology. For example, there is the TransparencyPct, TransparentColor & TransparentMode properties. And in the SetPixelGDIplus & GetPixelGDIplus functions, an opacity parameter is used.
But within my routines, the formula to determine the alpha value depends on whether an opacity value is expected or a transparency value is expected. A fully opaque pixel has an alpha value of 255 out of 255 while a fully transparent one has a value of 0 out of 255
To change pixel's opacity percentage (0-100%, we can simply use something like this: Alpha=255*(pctOpacity/100)
But if talking about transparency, then the formula is tweaked just a bit: Alpha=255*((100-pctTransparency)/100)
In either case, I think it is important to not confuse the two terms, opacity & transparency are antonyms not synonyms.
Originally Posted by VbNetMatrix
...
I'm surprised though that when I mentionned that bug you didn't answer me to check if I had the latest version. I mean, it make sense to me that if you already fixed the bug, you knew about it... unless it was a logic bug that you fixed and you never saw it in action...
You mentioned you downloaded most recent version, so any bugs in prior versions are history. Whatever the problem was, obviously it was corrected either because I found the bug or because of re-writing routines which I will do from time to time. This control is a year old now and when I see some code that could be much more efficient, I'll take the time to tweak it or re-write it. That could be how the previous bug, you were describing, got fixed.
Last edited by LaVolpe; Nov 8th, 2011 at 10:38 AM.
-
Nov 8th, 2011, 06:11 PM
#283
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
in any case, good control! and good work
the current revision is .26, the control with the bug was .16
not so far away (other version number was same)
-
Nov 9th, 2011, 08:56 AM
#284
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Originally Posted by VbNetMatrix
in any case, good control! and good work
Thanks. I found another bug in the cFunctionsICO class. It will fail to use any icon that is loaded by handle or stdPicture containing an icon. I inadvertently broke that part of the class couple revisions ago; will be patched this weekend. Been wanting to update some of the sample projects to include some of the latest enhancements
-
Nov 9th, 2011, 08:47 PM
#285
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
cool that you can fix it that fast...
-
Nov 13th, 2011, 04:12 PM
#286
Addicted Member
-
Nov 14th, 2011, 09:14 AM
#287
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Originally Posted by VbNetMatrix
I noticed something, it's not a bug per say... more a typo error.
The TOP property in the control is named "TOp"
... also I was wondering if theses 2 commands following each other should work like on the VbPictureBox object (meaning change size and retain it):
because as soon as it execute the second line, it revert to his original size...
AlphaImgCtl1.AutoSize = lvicSingleAngle
AlphaImgCtl1.AutoSize = lvicNoAutoSize
The TOp is annoying to me too. It's something I keep meaning to find & fix, but reverts back to TOp everytime I change it to Top. I'll find it & fix it once for all; probably a typo in the module somewhere.
Regarding changing size...
AlphaImgCtl1.AutoSize = lvicSingleAngle may have no effect, depending on the current control size & image size. Regardless, changing .AutoSize to lvicNoAutoSize will have no effect because the control will not resize again with that setting.
If you are attempting to resize the control based on the current image...
AlphaImgCtl1.Aspect = lvicActualSize
AlphaImgCtl1.AutoSize = lvicSingleAngle
If those properties were set during design-time, control will be self-sizing to whatever image is assigned during run-time
More details would be helpful
Edited: If you are discussing design-time, then what you are experiencing is by design. I've built the control using VB's image control as the model. If the Aspect property is lvicActualSize, then assigning a new image to the control will show the image actual size, regardless of the .AutoSize property. This is similar to VB's image control's Stretch property. If that property is False, any new image you assign to VB's image control will result in actual size image; otherwise, the control does not resize. At run-time, the behavior is not the same. The resizing of the control is completely dependent upon the .AutoSize property.
Last edited by LaVolpe; Nov 14th, 2011 at 01:36 PM.
-
Nov 15th, 2011, 06:18 PM
#288
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
I don't think I made myself understandable about that Autosize problem.
I'll post an exemple soon, but it doesn't react the way you explained it "should"
That seem to confirm I have a problem.
as for the TOp property, I know how to fix. I had a similar problem in past.
You'll have to Edit the file from external source (Ex.: Notepad++) as Vb won't allow this change to occurs because it is case insensitive, therefore he doesn't see the difference. Or, you can (in Vb) temporarely change the property to a different name (let's say "TopB") and then, remove the added caracter. it will then understand the change.
-
Nov 15th, 2011, 08:42 PM
#289
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Here I made a list, all you have to do is Change the "TOp" in the Declaration. Vb will correct it automatiquely all others place it appear.
here the list of Declaration with line number, use an external editor like Notepad++:
AlphaImgCtl.cls
79, 84 (Public Definition)
AicGlobals.ctl
100, 113 (struct definition)
GDIpImage.cls
434, 438, 440 (Public Property Get)
I fixed my side, it worked.
BIG WARNING THOUGH:
if compatibility is activated, UNREGISTER the file BEFORE compiling or you'll damage your registry.
fortunately, I knew how to fix manually but it was messy...
That's probably why Vb didn't wanted to allow the modification from inside IDE.
Last edited by VbNetMatrix; Nov 15th, 2011 at 08:58 PM.
-
Nov 16th, 2011, 01:52 PM
#290
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [7 Nov 2011]
Originally Posted by VbNetMatrix
BIG WARNING THOUGH:
if compatibility is activated, UNREGISTER the file BEFORE compiling or you'll damage your registry.
Not willing to break binary compatibility for such a small thing. I'll let others decide to do that for themselves.
Edited. I figured out how to make it stick without breaking compatibility. Next time I patch the control; I'll get that done too
For All: Uploaded patches today. Summary of changes
- Loading/saving of icons, pcx, tga, pnm, & pam files had a few logic flaws
- Can now save loaded AVIs to file, array, clipboard & another GDIpImage class. However, no support provided for creating AVIs
- Added a new RTF file that some may find useful: ControlProps.rtf
- Updated some of the sample projects (minor updates overall)
Last edited by LaVolpe; Nov 17th, 2011 at 09:07 AM.
-
Nov 19th, 2011, 12:21 AM
#291
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [16 Nov 2011]
sharing your finding could be nice, it's not the first time myself I'm faced with this problem.
-
Nov 19th, 2011, 10:33 AM
#292
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [16 Nov 2011]
Originally Posted by VbNetMatrix
sharing your finding could be nice, it's not the first time myself I'm faced with this problem.
Can't do that. My app lied to me. Once I recompiled, using binary compatibility, it once again reverted to TOp vs Top. It's just the way it will remain until a revision forces me to break binary compatibility. As I said before, not willing to break compatibility for a simple typo on my part.
P.S. Looking at the PDF source documentation & considering using them as a multi-image source. Will be playing with this over the next couple weeks as I find some time.
-
Nov 20th, 2011, 05:55 AM
#293
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [16 Nov 2011]
Regarding the "TOp" problem.
I've been in the same situation sometimes, but my case was about hWnd. Some people prefer it "hwnd" (small "w"), while I prefer it like this: "hWnd".
Normally, if you change the letter case in one part of the project, VB will change it everywhere. Unfortunately, there have been cases where tha change wasn't preserved after I reloaded the project.
What I do is: do a search & replace of TOp to Top, activating the case-sensitivity checkbox and setting it to search the whole project. Then, I save it, close VB and re-open it. Binary compatibility will not break just for changing the letter case, because COM is not case-sensitive. A very easy way to understand how it is possible, is late-binding, where we can type the procedure name using any combination of small and capital letters and it will still execute.
All you need to do after that is un-register and re-register the control.
-
Nov 20th, 2011, 09:46 AM
#294
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [16 Nov 2011]
Originally Posted by Cube8
All you need to do after that is un-register and re-register the control.
Individual responsibility. Re-registering it will likely create a new GUID. New GUID may prevent pre-existing apps using the control to not be able to use the control once it is re-registered. Fixing it in my project is doable, but when recompiled using binary compatibility, it will revert to TOp unless one of the steps mentioned earlier, is performed. When & if I do make changes to break compatibility with earlier versions, I will fix the typo
-
Nov 20th, 2011, 09:49 AM
#295
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [16 Nov 2011]
You misunderstood. I meant registering with regsvr32. The GUID is already inside the ocx.
The reason for un-registering and then re-registering (regsvr32 /u and regsvr32 respectively) is because the control's interface is cached somewhere in the system and we force it to rebuild it.
Last edited by Cube8; Nov 20th, 2011 at 09:54 AM.
-
Nov 26th, 2011, 01:57 PM
#296
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Control patched today.
Error found and corrected. When loading black/white icons/cursors by handle or stdPicture, calculation error wrote color table offset by 8 bytes resulting in incorrectly colored image.
-
Nov 29th, 2011, 12:37 PM
#297
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
sorry to be such a noob.. but I just downloaded and compiled the ocx and then added it to a new project. What Id like to do now is to be able to feed the control a string variable which contains the binary data (in string format ... as if you would open a .gif file in notepad++). Can this be done? Also, is GetPixel, SetPixel available on the control as well?
Thanks!
-
Nov 29th, 2011, 12:56 PM
#298
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Originally Posted by SeoChamber
sorry to be such a noob.. but I just downloaded and compiled the ocx and then added it to a new project. What Id like to do now is to be able to feed the control a string variable which contains the binary data (in string format ... as if you would open a .gif file in notepad++). Can this be done? Also, is GetPixel, SetPixel available on the control as well?
1) String containing binary data. I wouldn't suggest that. There is always possibility that bytes can be converted incorrectly depending on how you are loading the string. The simple answer is no. The control only accepts 3 types of strings: a) file path/name, b) url, c) Base64 encoded string
What you can do is convert the string to a byte array first, then send that:
Code:
Dim bData() As Byte
bData() = StrConv(imageString, vbFromUnicode)
2) GetPixel/SetPixel. Yes. They are global functions found in the AICGlobals class. These functions are available when an alpha image control is added to any form. Those functions are: GetPixelGDIplus & SetPixelGDIplus
-
Dec 20th, 2011, 11:42 AM
#299
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
-
Dec 26th, 2011, 08:25 AM
#300
Hyperactive Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Hey LaVolpe. You are the best person when it comes to Graphic usercontrols. I have a question. I am looking for a small simple usercontrol that i can display a bitmap or jpeg and mask a color. do you know of any such control. ( if not would you be able to create of advise code to use)
I know your Alpha Control can do this but dont need all the bells and whistles.
Many thanks
-
Dec 26th, 2011, 11:19 AM
#301
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Originally Posted by k_zeon
I am looking for a small simple usercontrol that i can display a bitmap or jpeg and mask a color. do you know of any such control.
I don't know of any, but it wouldn't be hard for you or someone else to create. I am not interested in creating specific, user-defined controls.
1) TransparentBlt API can draw a bitmap to a device context while masking a color
2) You many not even need a control, consider using a picturebox
If you have any questions regarding what I just mentioned, you should ask those questions in the appropriate forum. Please do not use this thread to continue this topic. This thread is for the Alpha Image Control, not some other control or non-related topics. Thank you.
-
Dec 28th, 2011, 09:39 AM
#302
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Please, can you explain how to load picture by code, without "CUSTOM" menu? Thank you.
-
Dec 28th, 2011, 10:10 AM
#303
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
In the zip file you downloaded, open the LoadPictureGDIp.RTF file. There are several examples on how to load an image during run time. Also in several of the sample projects, examples exist. The function you will use is called: LoadPictureGDIplus(). During design time, the "Custom" property page is the only way.
-
Dec 28th, 2011, 11:39 AM
#304
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Originally Posted by LaVolpe
In the zip file you downloaded, open the LoadPictureGDIp.RTF file. There are several examples on how to load an image during run time. Also in several of the sample projects, examples exist. The function you will use is called: LoadPictureGDIplus(). During design time, the "Custom" property page is the only way.
Oh, Thank you!
-
Dec 30th, 2011, 11:11 AM
#305
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Hey Lavolpe, I am a big fan and thank you so much for your gifts of knowledge!
I have a question, I would like to bring your control to the top of the zOrder but can't seem to. I am limited in knowledge of how this works. Is there a way to bring it to the front and maintain it's transparency appeal?
Just to clarify the reason: I would like to use the control as a button for a slider control or (on the form itself) so code can move it around when you left click on it and drag. So I must be able to load my image with transparency. I know I can place it on a PictureBox but the pictureBox background is square. Seeing the picbox behind the image control is undesirable.
Thank you in advance for replying
Mark
-
Dec 30th, 2011, 04:32 PM
#306
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Mark, thanx for the compliments. This is a windowless control. As such, its ZOrder will never be higher than any windowed control (i.e., button, slider, etc). The ZOrder does work in relation to other windowless controls (i.e., image, line, shape, label). Gotta think in terms of ZOrder, that this control is the same as a label, line, shape, etc.
The control cannot be made windowed and maintain its variable-level transparency. If a control only needed to have simple transparency (either 100% opaque/transparent); then it would be possible with the help of the usercontrol's MaskPicture property. But I won't modify the control for that limited purpose. There are examples of creating shaped usercontrols out & about.
Edited: Here's an idea you may be able to use. I won't discuss it further in this thread, but could address it if I saw it in the appropriate VB or graphics portion of the forums. With Win2K and above, we have the ability to create layered windows that can be shaped from any image. This layered window could be a form in your project. The image for that window can be loaded with my control, or not. By using the APIs SetLayeredWindowAttributes & UpdateLayeredWindow you can create a shaped form that appears when the drag operation begins, move the form while dragging, then unload the form when the drag stops.
Last edited by LaVolpe; Dec 30th, 2011 at 07:37 PM.
-
Dec 31st, 2011, 12:40 AM
#307
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Thanks... hmmm, might look into that. I did find a very suitable situation. Using your 32dbb DIB Suite from Planet Source, (which I have been using in the Frame and Button control that created) I use the image classes to create the image and rener it to the UserControl hdc. I sort of rig portions of the control in a modular rect manner like, border area, body, caption area, header, and such... THis has been a great way to deal with images and seems to be quite fast. So I just used that, stretched the image and set the corners to the closest rounded edge that is pretty close (as long as the object is not elliptical) and it works pretty well.
Here is a question that could save me a bunch of research if you would as I do not have the newer Os's? Using that older Dib Suite, should I expect any problems with Win7, Vista, or any other up-coming versions? Also, have you updated that since 2009's version on Planet Source Code?
Thanks you really are a great teacher!
Mark
-
Dec 31st, 2011, 12:43 AM
#308
New Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Oh, I had to chuckle, I feel like I am chatting with VB Royalty!! I can't begin to really thank you enough for the great work and your willingness to share your knowledge. Just thought I'd put that out there! Thanks!!!
-
Dec 31st, 2011, 12:33 PM
#309
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Mark, the DIB suite is fairly stable. I don't expect it should have any major issues. PSC has the most current version & it won't be updated. This control was based off of that to begin with. The major differences between the two are pretty much enhancements to this control:
- reads more formats; writes to more formats
- handles a few more rarer GDI+ bugs
- based on GDI+ images, DIB suite based on DIBs/GDI but preferred GDI+ for PNG/TIFF
- more graphical options
- the DIB suite was written to support Win95 also; this is really not but can be
- the DIB suite has 1 major advantage over this control and that regards writing PNGs. This control uses GDI+ only; whereas, the suite has code to manually create PNG with various compression algos & more options
Now back to your issue. If your image does not contain significant levels of transparency, i.e., simple transparency mostly, you can mimic what I suggested with already built-in methods, and with very good results:
1. Use a picturebox instead of my control for that floating window. Properties include AutoRedraw=True, BorderStyle=0
2. From the control/image class containing your picture, call the RegionFromImage method to return a windows region
3. Apply that region to the picturebox. Do not destroy the region in this case
Code:
' api you'll need
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
' shaping the picturebox
:: draw the image onto the picturebox or put my control in the picturebox at 0,0 coords, then...
SetWindowRgn Picture1.hWnd, AlphaImgCtl1.Picture.RegionFromImage(), True
' Image must not be resized. If it must be resized; you'll need to save it first to the new size.
' RegionFromImage uses actual size image only
' should you need to restore picturebox
SetWindowRgn Picture1.hWnd, 0&, True
The 1st parameter of the RegionFromImage method can be adjusted to allow/remove more semi-transparent pixels. See the comments for that function. Those that are allowed will not be semitransparent; they will be converted to 100% opaque. That parameter, whatever setting, ensures variable transparency is treated as simple transparency.
Apologize a bit. Should've thought about this solution earlier; but honestly, I just forgot I added that method to the control a couple versions ago.
Last edited by LaVolpe; Dec 31st, 2011 at 04:03 PM.
-
Jan 1st, 2012, 04:02 PM
#310
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Hi Lavolpe!
Happy NEW YEAR for you!!!
when crashing celebration will be over , could you tell me how you set up the Interpolation ?
By default it's set on AUTO, but how this AUTO mode is decided ? Because in all my project I have to fix it manually, I'm guessing my kind of project is not standart
Any documentation on this ? Would help me understand, maybe I'm doing something wrong.
regards.
-
Jan 1st, 2012, 04:20 PM
#311
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
The ControlProps.rtf that came with your zip should answer your question
-
Jan 1st, 2012, 04:45 PM
#312
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Ok I read....
now got 2 questions...
You're using lvicHighQualityBicubic when sizing is using.
if user is sizing 2 sides (height and width) it make sense.
However, if user size only 1 side (eitheir Height or Width),
lvicHighQualityBicubic is prone to error (I think) because in that case
(when user is sizing only 1 side) the desired effect is probably not
what lvicHighQualityBicubic is doing.
exemple: you got a 1pixel width (many pixel height) using some transparency and you want to make a BORDER of a frame...
in that case, lvicNearestNeighbor would be more appropriate.
Do you think it's worth including this "thinking" into the Auto mode decision ?
I can provide a physical exemple if my speech wasn't understandable.
question 2: Do you got something equivalent to LINE and CIRCLE ? if so, where is the doc about theses functions ? thanks.
(you're still the best, you very much inspired me in 2011 and I'm thinking about releasing my Access Database component in 2012, I just need to buil a website for it)
-
Jan 1st, 2012, 05:40 PM
#313
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
1) Maybe an example could help better describe the problem. Also include the Aspect & AutoSize properties you are using for the control.
2) GDI+ has API calls to draw a line and circle if you wish to draw them via GDI+. But you can also use the WantPrePostEvents property to draw the lines & circles yourself. The custom button sample project is an example of using that property and responding to the PrePaint & PostPaint events. You should also look at that RTF file again for more information on those events
-
Jan 1st, 2012, 07:36 PM
#314
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
1.
http://vbnetmatrix.com/download/lavo...erpolation.zip
You want to check out Middle part (Left Middle, Top Middle, Right Middle and Bottom Middle)
they are the part that are stretched. Corner are not stretched.
2. Will check that out... thanks for the info.
Would GDI+ be Faster ? for drawing line ??
because if I go to all the fuss ans wuzz to Prepaint postpaint and iT's slower, ... no need to reinvent the wheel, do I ?
what do you think ?
Last edited by VbNetMatrix; Jan 1st, 2012 at 07:41 PM.
-
Jan 1st, 2012, 08:22 PM
#315
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
1. Ok, I see what you are talking about. No, I do not agree the logic needs to be changed. You are stretching an image that is 1 pixel in width or height. Different interpolation algorithms will render different results. The "auto" selection may not be ideal for every possible situation, but it will be for a majority of the cases. Since the control allows you to opt for different interpolations, I think that is good. Keep in mind, most people will not be using this control to stretch a 1 pixel image, they will be using it to display pictures vs. lines
2. Regarding drawing lines or circles. The Pre/PostPaint events really are not slow. When the property is set, a bitmap is created that lasts until WantPrePostEvents is set to false or the control is destroyed. Unless the image is nearly full screen, you shouldn't see any differences in speed.
Now it all depends on the quality you want for your circles and lines. A circle drawn with VB or GDI32 apis will not be alpha blended but are far easier to use. If you want smoother/blended edges for circles and diagonal lines, GDI+ may be ideal. You will still use Pre/PostPaint events, create a GDI+ DC, create a GDI+ brush and/or pen, set the interpolation for that DC, then draw a GDI+ line or circle. Browsing the graphics portion of the forum could be useful if you are not familiar with GDI+. This is one of my favorite GDI+ sites, but it is not really friendly to VB language. If I see questions regarding GDI+, I usually try to help, but won't use this thread for a GDI+ tutorial.
-
Jan 1st, 2012, 08:39 PM
#316
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
"Keep in mind, most people will not be using this control to stretch a 1 pixel image"
1. Yeah I know what you mean, that's why I said "changing the logic for that particular case" maybe it wasn't phrased that way but that's what I meant. Most people will not use the control that way, it's true. But thoses who will are expecting that result, right? meaning, a simple test inside control
If (Streched X AND NOT Streched Y) or (Streched Y AND NOT Streched X) then
Interpolation =3
else
Interpolation =0 'Auto
end if
But now that I'm aware of the problematic, it's probably simpler to SET my control in the begining... I'm agreeing with you... But since people using that particular mode of stretching are probably seeking for that kind of effect it seem pertinent to insert the logic...
2. Why hDc of the control is available only at postpaint event ? can't we write directly on the control ??? I failed to find a Gdi Exemple that would allow me to paint directly on the control without hDc. I probably missed something.
and yes, my control is fullscreen, so yes I think best way would be to use GDI... or learn more about creating a png directly using your control...
thanks. I would never say enough how much your control is apreciated.
-
Jan 1st, 2012, 09:18 PM
#317
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
Originally Posted by VbNetMatrix
2. Why hDc of the control is available only at postpaint event ? can't we write directly on the control ??? I failed to find a Gdi Exemple that would allow me to paint directly on the control without hDc. I probably missed something..
The control is windowless, it gets it DC from its container only during the control's Paint event. During the paint event, it then sends you the DC thru the Pre/PostPaint events if requested. But it really isn't the actual DC because that DC is clipped and offset; so a temporary DC is sent instead that will cause problems if you draw outside of the actual control which is possible if the real DC was sent. There is no DC to draw on directly.
-
Jan 1st, 2012, 09:52 PM
#318
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
ok, so if I understand correctly from previous post...
1. the control is windowless because otherwise it wouldn'T allow full transparency
2. a windowless control obviously doesn't have a direct DC
3. if using the dc from pre/post paint event, I draw OUTSIDE the control, it can be dangerous ? like crashing issue ?
4. is there any way to temporary "CreateDc" using GDIpImage and SAVESTRUCT ? (I'm probably just half stupid)
-
Jan 1st, 2012, 10:10 PM
#319
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
1) Yes regarding variable translucency. If GIF-like transparency, no blending, then that can be done a few different ways. But that would remove semi-transparency effects
2) No, it can. But I chose not to for 2 reasons: a) uses less resources, b) I'd still have to get VB to paint the container's bkg to the DC
3) No, crashing is not the issue. When VB sends the control a DC, it is clipped and offset so that 0,0 coords of the DC line up with the control and the width/height of the DC is the 'dirty' area to be painted by the control. The DC is actually the entire container. Now if someone were to mess with the DC and remove or adjust the clipping region contained in it, the entire container becomes the drawing area instead of just the area occupied by the control. Also, it would be possible to inadvertently corrupt the DC. This is the reason I do not send users the actual DC, but I send them an offscreen DC which I then paint to the container
4) Don't understand. Maybe you can describe what you are trying to do that the control isn't allowing you to do
-
Jan 2nd, 2012, 12:43 AM
#320
Addicted Member
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [26 Nov 2011]
2. b) ?? I didn't understood what you meant about the Vb Paint.
3. clever... I like it... it's like when I use a control to Subclass, if it crash in the Subclass only my control crash and not the full app. and I can still Debug...
4.) I need to use direct drawing function like MoveToEx and LineTo (Api)
wich I failed to perform... So I probably misunderstood you properly when you said I could use Gdi+ function... I looked up the web site you gave, but I have no idea where to start my search so unless I read all the 563 pages bible on GDI (Wich is very interesting by the way) I don't know where to look or even what I'm looking for...
I need to draw a New GdiIpImage that is 1024x768 (screen size) in size
with transparency. So unless I figure out how to perform that many SetPixelGDIplus in less then 3 second, I need to find another way...
one thing that could help was if I had an already prepared Array of pixel like a BitBmp map I could use and only change the part I need to... wich is adding some line...
now the problem lie in the fact that I don't know the Size Screen of all client and it's possible it would not always be 1024x768...
one possible solution if I can't find another way would be to limit my program to a few different size, and prepare semi transparent background image that I would just load and then make the change (still need to draw line in it) on the fly...
any thought, suggestion, protocol and documentation would be great. You are still the one knowing this control more then anybody...
thanks for all..
Tags for this Thread
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
|