Sorry. I have a thing, call it quirky, helping others make money off of my code. I've given you lots of help. I trust you can spend the time to troubleshoot that last issue.
Printable View
Sorry. I have a thing, call it quirky, helping others make money off of my code. I've given you lots of help. I trust you can spend the time to troubleshoot that last issue.
Sorry, but I have expressed myself wrong when he said "work" was referencing "school work", do not know what the term used in your language, and if you can help me I will be very grateful, including its control along with the link of this forumIt is attached as a reference in my "school work".
But still I am very grateful with all your help so far and I take once again to congratulate his wisdom.
Ricardo Vieira Pulo (17 years - eighth computer technology class)
(São Paulo Brazil)
translation - google
I tried to explain this at least two times. If you want the correct result, your Render parameters must be the same in both the PrePaint and CmdCut events. They are not the same. If you fix that, maybe your problem can be resolved.
P.S. I could not load your project, could only look at the code. I do not have your version of the alpha image control, nor do I have the threed ocx. No biggie. I think your problem is related to the different rendering calls; thereby producing different results.
about that... I always wondered why you don't have a "donation" button. I know I offered it to you in past but I would be very honored to offer you a web page host. All you have to do buy the domain (about 10$ per year) and I would web host your domain and you would have full control over the web page. I really apreciate your control, it's the least I could do. I would be glad to "donate" myself to you.
After selecting the region and show the PicCanvas, saving the piccanvas?
VB's SavePicture function will save the picCanvas.Image to a bitmap
Hi, firstly thank you for your amazing code.
I am facing a issue when printing an image.
The code uses the same routines to draw either in the screen or in printer.
It uses the vb scale methods of own each object (picturebox or printer) to define de position given in millimeters.
However the render method of AIC just prints near the right position when I use the same coordinates used in the picturebox and add a magical offset (27 pixels horizontal and 43 pixels vertical)
More over the image was trimmed in the rendering.
The image was loaded from a byte array read from a data base field.
Original image: Attachment 131319Code:Set myImg = New GDIpImage
myImg.KeepOriginalFormat = False
Set myImg = LoadPictureGDIplus(myField.GetChunk(0, myField.FieldSize), False)
Set myEffects = New GDIpEffects
myEffects.TransparentColorUsed = True
myEffects.TransparentColor = GetPixelGDIplus(myImg, 0, 0)
'Expected to work
'With IIf(mbPrinting, Printer, myPicBox)
'myImg.Render .hDC, _
.ScaleX(mnLinAssPosX + mnMargemEsq, vbMillimeters, vbPixels) + .ScaleX(mnRTAssImgOffSetX, vbTwips, vbPixels) - myImg.Width / 2, _
.ScaleY(mnLinAssPosY + mnMargemSup, vbMillimeters, vbPixels) + .ScaleY(mnRTAssImgOffSetY, vbTwips, vbPixels) - myImg.Height / 2, _
, , , , , , , myEffects.AttributesHandle, , myEffects.EffectsHandle(lvicNoEffects), lvicHighQualityBicubic
'End with
'Atcual work
myImg.Render IIf(mbPrinting, Printer.hDC, myPicBox.hDC), _
myPicBox.ScaleX(mnLinAssPosX + mnMargemEsq, vbMillimeters, vbPixels) + myPicBox.ScaleX(mnRTAssImgOffSetX, vbTwips, vbPixels) + IIf(mbPrinting, 27, 0) - myImg.Width / 2, _
myPicBox.ScaleY(mnLinAssPosY + mnMargemSup, vbMillimeters, vbPixels) + myPicBox.ScaleY(mnRTAssImgOffSetY, vbTwips, vbPixels) + IIf(mbPrinting, 43, 0) - myImg.Height / 2, _
, , , , , , , myEffects.AttributesHandle, , myEffects.EffectsHandle(lvicNoEffects), lvicHighQualityBicubic
Results
Have you ever dealt with such issue?
Thanks in advance.
Best regards.
Looking at your screenshot. The picturebox rendering is correct? Obviously the Printer version is not. It appears the printer may be slightly scaling the rendering. I say that because 1-pixel edges when scaled can be lost or thinned out when scaling. Though you are not scaling the rendering, just assigning the X,Y printer coordinates.
I assume the printer's scalemode is pixels. You may want to check the results of your X,Y calculations and see if rounding may be an issue. Don't know if it will help or fix the problem, but try passing whole number vs fractions, i.e.,
CLng(myPicBox.ScaleX(mnLinAssPosX + mnMargemEsq, ... )
CLng(myPicBox.ScaleY(mnLinAssPosY + mnMargemSup, ... )
I created a simple project to find out the causes and I found one of them.
The effects to make the color transparent is responsible for trimming the image.
Printer (PDFCreator) Result: Attachment 131323Code:Dim oGDIImg As LaVolpeAlphaImg.GDIpImage
Dim oGDIEffects As LaVolpeAlphaImg.GDIpEffects
Set oGDIImg = LaVolpeAlphaImg.LoadPictureGDIplus("C:\myImg.png")
Set oGDIEffects = New LaVolpeAlphaImg.GDIpEffects
oGDIEffects.TransparentColor = LaVolpeAlphaImg.AICGlobals.GetPixelGDIplus(oGDIImg, 0, 0)
oGDIEffects.TransparentColorUsed = True
Printer.CurrentX = 0
Printer.CurrentY = 0
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 28
Printer.Print "Just a small block of"
Printer.Print "text to show that the"
Printer.Print "image is printed with"
Printer.Print "true transparency and"
Printer.Print "not simply with a white"
Printer.Print "background."
'LaVolpeAlphaImg.PaintPictureGDIplus oGDIImg, Printer.hDC
With Printer
.ScaleMode = vbPixels
'oGDIImg.Render .hDC, (.ScaleWidth - oGDIImg.Width) \ 2, (.ScaleHeight - oGDIImg.Height) \ 2, , , , , , , , oGDIEffects.AttributesHandle, , oGDIEffects.EffectsHandle(lvicNoEffects), lvicHighQualityBicubic
oGDIImg.Render .hDC, , , , , , , , , , , , , lvicHighQualityBicubic
oGDIImg.Render .hDC, oGDIImg.Width, oGDIImg.Height, , , , , , , , oGDIEffects.AttributesHandle, , oGDIEffects.EffectsHandle(lvicNoEffects), lvicHighQualityBicubic
.EndDoc
End With
Do you have any suggestion to workaround with image loss with the transparent effect?
I am still working to find out the reason about position issue using the same scale of the picture instead of printer dimensions.
Thank you very much for your fast response.
Best regards
Finally I found a workaround for the printing issue.
To avoid that trimming of image happens, I created a picturebox 2 pixels wider (in both dimensions horizontal e vertical) than the image, then rendered the transparent GDIpImage with an offset of 1px and after i rendered in the printer DC.
On regards to position problem, I figured out that there is a difference between screen and printer. Coordinates in pixels used for the printer have to be increased in 4% to be correctly positioned. I still do not know the reason, but now is printing very fine.
Hello LaVolpe.
I didn't really understand the reason behind the size limitation to screen size when the selection of the Aspect is something other than lvicActualSize. Can you give some details?
Don't have a great reason, but I'll give it to you. You cannot physically view more than the screen size. Very large images require large amounts of memory.
The control was not written with the idea that it could be used as a view port. There are limitations on the size of any image backed by a DIB or bitmap. Those limitations are not public from Microsoft as far as I know, but to avoid potential errors I simply took the easy way out, expecting this to a be a problem for a very small percentage of typical users.
In my rewrite of this control (still not close to publishing it yet), this is one topic I still haven't found a great solution for. I personally don't like the limitation. I am close to finalizing a solution that won't be perfect but would remove the limitation. The solution is basically to use GDI+ (which has its own methods of handling large images) and rendering on demand the viewable portion of the image. This solution could negate AutoRedraw for very large images because of the DIB size limitation imposed by Windows. I would expect rendering to be significantly slower in these cases, especially if AutoRedraw is not applicable and/or image appearance is changed during rendering: scaling, rotation, mirroring, gray scaling, etc. Very large images may not be able to be saved, without scaling, to other image formats where the format itself restricts max dimensions. All being said, if GDI+ balks at loading very large images, all bets are off.
In any case, I do always foresee a max data size of 2 GB as a permanent limitation.
Hello LaVolpe.
I am facing the following problem: in IDE (debug-time) I can load a picture to an Alpha Image Control from the picture property of a Standard Image Control, however when is in run-time (compiled) the error 481 - Invalid Picture is raised.
---------------------------Code:Set AlphaImgCtl1.Picture = LaVolpeAlphaImg.AICGlobals.LoadPictureGDIplus(Image1.Picture)
Project1
---------------------------
Run-time error '481':
Invalid picture
---------------------------
OK
---------------------------
Could you help me to solve this?
Thank you very much.
I'll take a look, but not likely in the next day or two. I am always interested in errors and bug reports.
In the mean-time, try passing the handle: Image1.Picture.Handle
Edited. A quick look, I was able to replicate the problem twice in a row. Then problem went away without doing a thing. I think I have it narrowed down, but will have to perform more tests. If I do figure it out (and I will), you will have to make the change to your copy of the control & recompile it. If this is the only issue and if passing only picture objects that contain bitmaps or jpegs, would recommend passing by handle vs the picture object. That way you won't have to modify the code, recompile, & redistribute the ocx.
Follow-up. To patch the bug:
Method: modCommon.pvProcessStdPicSource
Add this: bSaveMemCopy = True
Where:
Code:...
If IPic.KeepOriginalData Then
....
Else
bSaveMemCopy = True ' << insert here
IPic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
End If
...
Hello LaVolpe,
Can you check into the code of PhotoDemon - The open source photo editor. It supports very large image size. It is open source so you could study its source cod and implement interesting features in the new version.
http://photodemon.org/
Just my 2 cents.
Very familiar with that project and the author. Not interested. My control is not designed as a photo editor, never will be. It is designed as a viewer. The goal was to expose the control to the user via properties and events so that the user can draw onto the control to customize the image all they want. That was always a shortcoming to VB's controls. The picturebox was the closest we came to custom drawing images.
Thank you for your -always- quick reply and for the answer.
I look forward for the new version of your control. :thumb: :thumb:
What you describe couldn't happen even with this version of the control with a very large image size if Aspect is lvicActualSize ?Quote:
Very large images may not be able to be saved, without scaling, to other image formats where the format itself restricts max dimensions. All being said, if GDI+ balks at loading very large images, all bets are off.
(I didn't test this since I don't know exactly how large has to be the very large image in order to cause problems).
Yes it is possible. TIF for example is not uncommon to contain very high res images at 600 DPI or higher. VB will not allow a control to be sized greater than 16383 pixels. Translated down from 600 to 96 DPI (normal), that's rounded up to 2625 pixels, though the image dimensions would be 16406. Without DPI awareness, the control will attempt to load the image treating it as 16406, at current screen DPI, regardless of its actual setting. The lvicActualSize setting requests the same size as its dimensions & failure will occur. If AutoRedraw is requested, not sure if the O/S would allow, say a 16406x16406 bitmap, to be created. Memory-wise at 32 bpp image, over 1 GB of memory needed.Quote:
What you describe couldn't happen even with this version of the control with a very large image size if Aspect is lvicActualSize ?
Granted that 2625 pixels scaled from 96 to 600 DPI is 16406, but is 2625 realistic? How about half that at 1200 DPI? Same result.
Again, it is possible. Likely? No. But to be a more bullet-proof control; this is an issue I'm attempting to find a good, usable, solution for. The best I've come up with so I don't have to create my own 'view port' is to rely on GDI+. If it can load it, then it can likely display it. The size of the image control is limited by VB, but that limit is larger than the screen so no real issue there.
Thank you, again.
Now everything is fine, great work.
You are awesome.
Hi LaVolpe.
In a step forward, I dealed with the following issue, again it only occurs in run-time, in the debug-time within the IDE is just fine.
There is a quality loss in run-time when we load a picture from a IPictureDisp or StdPicture directly from its pointer.
If we load passing the handle porperty, instead, it works and the image is recovered perfectly.
However it does not apply for metafiles (.emf or .wmf), an error is raised when we try to load from the handle, either in run-time or debug-time.
Here goes the project sample.
What I suspect you are experiencing is a little known behavior of VB.
1) Loading WMF,EMF by handle isn't supported in this version of the control. Just send the picture object.
2) When you load a bmp/jpg by the object, you should not experience any quality issues.
3) When you load GIF by handle, compiled or not, or by object, when compiled, you will lose transparency
4) When you load icon by object, when compiled, you would lose quality if I didn't foresee that problem.
For #3 & #4 above, here is why. During design-time, uncompiled project, VB caches the original image data when it creates a stdPicture object. I believe this is simply so that VB can save the original data with the project in the .frx, ctx, and other project files. But when your project is compiled, VB does not save this data any longer when it creates the stdPicture object, it doesn't need to, for its purposes, because it knows that data is not needed for saving to project files.
Ok? When you pass the picture object to be loaded, my control's logic works like this:
1) Icon? Always load by the object's Handle to avoid VB's color reduction
2) Anything else: If VB kept the original data, use that data to load the image (as mentioned VB doesn't save this data when compiled)
3) If no original data exists, code asks VB to create the data. This is where VB is really bad with icons and GIFs. GIFs/JPGs are saved in bitmap format. GIFs lose transparency because internally by VB/COM, they are bitmaps not GIFs. Icons are color reduced down to 16 colors resulting in poor quality. You should see these quality issues if you viewed the result of the image file created by VB with: SavePicture "c:\test images\filename.ext", Image1
Note: Even if the original metafile data is not provided in the picture object, VB can recreate metafiles flawlessly
This behavior of VB needs to be understood if passing picture objects to anything, to be used as image source data.
Suggestions if these formats will be used by the alpha image control (AIC) after your project is compiled:
1) GIFs. Load these into a resource file. Pass them via LoadResData()
:: doing so, ensures all frames are available & transparency is preserved
2) Icons. Same as GIFs. You could also use VB's image control since the AIC uses the icon handle
:: using res file ensures all sub-icons are available if more than 1 icon exists
3) Bitmaps. Any method you want
:: stdPicture objects processed by ignoring alpha channel. If channel is used, pass by handle
4) JPGs. Load these via resource file if the original image data is needed by you. Otherwise, any method will work
:: saving a JPG loaded by VB to JPG format causes recompression of original data
5) WMF/EMF. Any method you want, but don't try to load metafiles by handle
:: see notes below
6) Any format not supported by VB: use the resource file method or disk file
Edited: I see you use this quite a bit: LaVolpeAlphaImg.AICGlobals....
Just FYI, shouldn't be necessary if you don't want to: Set AlphaImgCtl1.Picture = LoadPictureGDIplus(Image1.Picture)
Edited Again. A bit more about metafiles if trying to pass by handle
EMFs can be processed a couple different ways from its handle. This is not a major issue to support passing EMF by handle. However, WMFs are a different story...
When you have a WMF handle, you have a handle to its bits, its drawing commands. Without analyzing each command to determine where & what dimensions each command is attempting to draw to, there is no way I can think of to get the dimensions, nor aspect ratio of a WMF strictly from its handle. With the handle only, what we have is basically a non-placeable WMF -- no dimensions, no aspect ratio. In my own version of this control, WMFs passed by handle are treated as non-placeable and user has option to set dimensions. GetObjectType API helps identify type of image handle.
Hi
Same problem here, seems strange, I have two developer machines, the first one with Windows 10+VB6 runs ok, the oher with Windows XP+VB6 shows error 481 loading the same JPG.
I've tried to apply your patch but that piece of code does not apperas in pvProcessStdPicSource:
I've found this:Code:...
If IPic.KeepOriginalData Then
....
Else
bSaveMemCopy = True ' << insert here
IPic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
End If
...
Anyway I've added the line there and still error 481 :(Code:If ipic.KeepOriginalFormat Then
ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
If lResult = 0& Then ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
Else
ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
End If
@tbote. Instead of True,False, try using 1&,0& respectively. That appears to work well in a recent project I uploaded to the codebank
Edited: If the error is still occurring, please let me know. In this version of the control, I have no low level code to manipulate the IStream (COM interface). Continued failure would likely result in a need to reset the stream's Read/Write pointer to the 1st byte before attempting to call IPic.SaveAsFile. Hoping that passing 1& vs True (-1) will nip this annoying inconsistency.Code:If IPic.KeepOriginalFormat Then ' from COM-cached data
IPic.SaveAsFile ByVal ObjPtr(IStream), 0&, lResult
Else ' from COM-created data
IPic.SaveAsFile ByVal ObjPtr(IStream), 1&, lResult
End If
P.S. That error is self-generated in the code. If the LoadPictureGDIplus fails to return an image, it raises the error.
Hi LaVolpe,
I have been looking at using the excellent alphaimage in some of my vb6 apps, and wondered what the situation is with using it in a commercial application, i.e. if I choose to sell an app.
Is it allowed? And how am I best to credit you as the author in my code/application?
Many thanks
Craggus2000
:wave::wave::wave:Does who know the status of Lavolpe? He was offline since 5 march 2016.
Hi Lavolpe.
I can't thanks you enough for your contribution for Vb6.
if you could allow myself to benefit once more from your knowledge, I would greatly apreciate it.
How do you manage to "draw" on a transparent OCX ?
I'm using the "bonus code" (of another of your project) to draw a transparent png on a form.
it work perfectly.
but when I try to make an OCX out of it, (I'm forced to use Transparent background of the OCX properties)
the image doesn't show.
So I was wondering how you do it in AlphaImage control. This control is so huge, it is hard for me to trace how you do it. if you could just spare some of your time to made me benefit from your knowledge. plz.
Hi Lavolpe,
I follow you on other forum and continu to appreciate your knowledge and wisdom.
I know this project is not updated anymore. But I though... maybe a bug report would revive your flame about it :)
(but if not, thanks anyway for all you gave us in the past)
I'm really trying to fix this for a project of mine...
if I take an image (png) of let's say 1(width) per 20(height) composed of 1 color (mine is more complicated, but this does same thing)
and apply the following:
Aspect: 1- lvicStretch
Interpolation: 3- lvicNearestNeighbor
Then on the form, I stretch the picture to let's say 200pixel using
then here the problem...
I try to apply an effect:
Call aicLine.Effects.CreateColorBalanceEffect(16, 0, 100)
aicLine.Effect = lvicColorBalanceFX
The first (about) 16 pixel (width) are totally white (all height)
any idea for a quick fix ?
if you're interested in the challenge, I can post my code and the image on an ftp.
thanks again.
hi again.
can u help me about this ? https://stackoverflow.com/questions/...nt-form-in-vb6
i posted here too http://www.vbforums.com/showthread.p...75#post5127975
i want read psd file and layers in it and then show on dekstop (on a transparented form). i found source for read psd and show layers in form but cant show on desketop like transparented form.alpha image control can not support psd format and layers?
Hi
I want to try to help you.
can you explain more because I'm not sure what you're trying to achieve. First, you need to understand PSD ARE NOT IMAGE. It's a DOCUMENT. it's not like a BMP (image) wich can be opened in paint and wich property DIDN'T change since the creation of this image format in the 1980. PSD is a propriatary form of document that has no fixed property. That mean, a PSD file from let's say Adobe Photoshop 4 is completely different then a PSD file from Adobe Photoshop 10.
What I need is to know what you're trying to achieve.... Show "each" layer of the PSD document on the desktop? or show the "resulted" end layer ? (visible image) ?
if you're tying to show the end result, it would be better to export the PSD as a PNG file and then you'll have an alpha transparency image you can show on the desktop. (It can be achieve with some API)
i want use PSD file format only because matter for me and a simple version of adobe so for example adobe photoshop 8.
my steps are :
1- designed a psd file in photoshop with more than 1 layers for example 2 or 3 or 4 or more.... and saved like sample.psd.
2- in vb6 can read sample.psd and can read layers and then show each layers in one form or can read all layers and show all layers on one form and then i want transparent form becase i like show just layers without form like show on dekstop effect.
3- i want cam hv been event for example when a layer shown then can click on layer on when moure overed show another layer.
and can u explain this in other forums about alpha control and psd format:
"Maybe you missed that the control is provide with full source code, so you should add your code to read PSD files among the other formats. Take as example the cFunctionsTGA.cls and do the same with the PSD. " what that means do u hv any example to i can understand this means?!!!
my language is not english.
Again, as VbNetMatrix said, you can't use a psd file in any way in VB. It is a proprietary file format, created by Adobe for use specifically by Photoshop.
http://www.makeuseof.com/tag/the-bes...out-photoshop/
If you want to make a psd reader in VB, you are free to analyze the File Format Specification provided by Adobe.Quote:
The problem is that PSD is not an open format. While PNGs, JPGs, and BMPs can be opened in nearly every image editor out there, PSD is special — and it needs special support.
As Cube8 mentionned, PSD is propriatary... meaning, Adobe can stop supporting a specific format. For example, you can't open PSD version 1 anymore because they were in conflict with the new design model they later develop. if for example, you currently build an application supporting PSD v8 and in 3-4 years Adobe decide to stop supporting this version, no program will be able to "save" in that version, meaning what you're currently developping will be broken. this will never happen with an open Image format (look at BMP, obsolete but still usable)
better export that PSD in PNG (many if you need separate layer) and use thoses. It will be faster and you won't need to support a format or programming a read method.
this picture can show what i want :
Attachment 144195
now you confuse me... you showed on right image you CAN DO IT.
if you can show the image on Vb6 form, where is the problem ??
just use SetLayeredWindowAttributes API
https://bytes.com/topic/visual-basic...6-transparency
I thought the problem was to show the PSD layer ?
i used SetLayeredWindowAttributes API but result was been this image (not good).
i checked source code and can find this code :
this is main command for read from layer data and theHdc is same form.hdc .Code:SetPixelA theHdc, x + FLeft, y + FTop, r, g, b, a
i added SetLayeredWindowAttributes API after form load and checked and added after end of show layers and checked but result was been like attached my image,how can make good quality with shadows or ... ?
Attachment 144223
can i send source code and maybe u can fix it for me?
post this to the other thread, I don't want to pollute Lavolpe AIC place. I'll help you solve this with AIC
i sent source code in this thread [http://www.vbforums.com/showthread.p...7#post5129607]
i hv 2 question about this thread too (alpha image control).
1-how can make smooth animation (other way not use for next commands) and want show that animation on desktop with mouse event too?(can click on animation or drag and drop)?!!! possible?
i want show animation (smooth) on desktop like attached image but png format and transparented :
http://gifyu.com/images/demoa6640.gif
if possible can attach source code or sample code ? thanks
2-this control can support apng format?if not how can simulate this format with png ?
Lavolpe AIC support APNG, and mouse driven event. if you use your program with the previously discussed API, you can make your form transparent while supporting event on the image.
can u send a sample source code animation merged with form controls and show on desktop use by AIC?
i have source for show animation on desktop with AIC but i can not merge controls like textbox or button or shape or ...
i dont want use trick like show animation on one form and show controls like as top form on animation.i want just use one form with aic control and form's controls.
Attachment 144311
Use eitheir an animated GIF or an aPNG (animated PNG) when you need the animation, you use:
aicPng.Animate lvicAniCmdStart
as simple as that. (1 line of code)
did you installed the AIC ? if so, you can get nice APNG here: http://voormedia.com/blog/2016/09/an...ng-compression
my means was been about sample source code animation merged with form controls and show on desktop use by AIC?
i have source for show animation on desktop with AIC but i can not merge controls like textbox or button or shape or ...
my problem is about merge controls like text boxes or command buttons or shape or ... when i use aic and then maked transparent.
did u see picture attached in #582?
see this result (how can fix it?): http://s.pictub.club/2017/01/27/sr2WTY.gif or http://s.pictub.club/2017/01/27/srBsIm.gif
and i have another question
1- i have a animation with 20 frames and dont need loop animation just need 1 loop time.
2-how can start animation from frame 3 when form loaded or show.
3-then play from frame 3 to frame 12 with my custom speed?
4-when frame was been 12 then stop 2 second.
5-then start animation resume from frame 12 to frame 15
6-then animation jump to frame 18
7-play animation resume from frame 18 to end frame(frame 20)
simple apng images needed for vbnetmatrix request :Attachment 144581
I have a project which uses Alpha Image Control (AIC), it works fine on my development machine and clients who have Windows 7 but AIC does not show the image (blank control) on "some" Windows 10 machines, any clue?!
Any clue? Gonna need a lot more info than that. I have Windows 10 and no problems. It might help to know whether this problem is for every instance of the control? Whether you are talking about the control displaying or using one of its functions to draw to a picturebox or other DC? Whether this seems related to a specific image format? etc, etc. Without far more details, I am not gonna be able to venture any guesses or suggestions.
Also, for the control(s) that don't display correctly, post the LoadPictureGDIplus statement you are using. See if post 553 & 554 on previous page apply, along with post 561, 562 & 563 on this page.
Thanks Lavolpe!
Actually I am loading an AVI file not a picture, though I am using LoadPictureGDIplus() to load it into the Picture property of the AIC.
I have like a custom made thumbnail viewer and using the following code to populate it :
Normally it should look like this when all is OK :Code:Private Sub ThumbnailViewer()
On Error Resume Next
Dim tmpFL As String
Dim n As Integer
For n = 0 To 4
With imgThum(n)
tmpFL = CURRPATH & "\" & flAviFiles.List(n + SlideIndex)
If Right$(tmpFL, 1) <> "\" Then
.Picture = LoadPictureGDIplus(tmpFL)
.ToolTipText = " " & Lang(20) + " :" + Str$(n + SlideIndex + 1) & " "
If Dir$(Replace$(tmpFL, ".avi", ".ini")) <> "" Then .BorderColor = vbRed Else .BorderColor = vbBlack
.Visible = True
Else
.Visible = False
End If
End With
Next
End Sub
Attachment 150363
On some versions of Windows it looks like this :
Attachment 150365
P.S. :
* The DivX codec is installed on all clients machines.
* flAviFiles is a 'FileListBox' control with a pattern of *.AVI
* Lang() is an array which loaded with different languages text
I know you will figure out the the above two lines but I had to write them anyway :)
When you have the the time, open this class module within the AIC project: cFunctionsAVI. Read the comments at top of the class and see if they apply.
Also regarding this line: .Picture = LoadPictureGDIplus(tmpFL)
After that statement returns, test to see if .Picture.Handle = 0. If it does, the AVI failed to load using the AVIStreamOpenFromFile API or the AVIFileInit API failed (not likely).
Also ensure this line is true: If Right$(tmpFL, 1) <> "\" Then
I can play with this further if you can't get it working based on the comments in that class. But I'll need the AVI and a link where to get the codec. I can't guarantee I'll get to play real soon; have other things on my plate right now. My 1969 Mach I Mustang just died on the way to work and dealing with that today, off and on.
I feel you man. :(
wich part broken ? did u succeed to get replacment ?
in the meanwhile, I wanted to ask you a question about the AIC. In a project of mine, I add the reference to the component but I didn't used it (yet). Inside the IDE, I was debugging the app wich also use the MsFlexGrid and WinHttp component. All 3 component I used in different application (but never all together) and I never had any problem. In this particular project, the AIC was referenced but not put on any form. the IDE experienced "Out of Memory" error from time to time when the program "end" normally or "stop" from the IDE.
removing the AIC reference, fixed the problem, but I fail to see how a reference to AIC without initializing it or using it on form could lead to that.
Did you ever experienced similar problem ? Seem a rather unexplained problem. I didn't tried too "reproduce" it since I had to deliver the application in a hurry.
any idea ?
thanks for any feedback
Out of Memory isn't related to the AIC as far as I can see. I've taken great efforts to ensure no memory leaks. The control, when first used or any of its global methods are used, will create a GDI+ token.
If a control is used, then other items may be created like a GDI+ image and/or bitmap, depending on options/settings of the control. However, even if there is a memory leak, I'd think one would need 100s of controls to cause that problem. Again, as far as I know, there are no leaks and with 1000's of downloads, this was never brought up previously. A quick test, using Task Manager, shows that the GDI count before a project run with the AIC, increases while the project is running (expected), and returns to that value after the project is closed. Pretty confident no leaks.
Out of memory can occur in a recursive routine also. If you have any recursive routines look at those. In the AIC control there are 3 places where recursion can occur. Those routines include async downloads via URL, creating adaptive palette option when saving image in low color depth, and when autosize of the control is set to true and a potential of resizing entering an infinite loop. In all of those, I've included code to prevent unexpected recursion.
Are you by chance running any code that tries to resize controls based on form_resize? Maybe that could be an odd case that could cause an infinite loop if your code is forcing one size while the control's AutoSize feature is forcing another, maybe just a pixel off? But if you don't even have any controls sited on the form, that won't be in play.
That is odd indeed and may be coincidence. Maybe you can try it in reverse order. Add the AIC first, then the other references, one by one. Do you get the same results? If the control is not even sited on a form, no code is running so this is unusual. If you can reproduce the problem on demand, that could be helpful. Maybe there is some sort of race-condition being created between the AIC and the other references?Quote:
but I fail to see how a reference to AIC without initializing it or using it on form could lead to that.
Edited: When you get that message box, is it possible to break into the code to see what line is being executed? That would help.
The only issue I know that can happen is addressed at this posting. However, this problem is not specific to this AIC, it is applicable to any VB-created usercontrol when environment is manifested.
BTW: Mustang will need a new dizzy. Been waiting for the makeshift one I am using to fail so I can spend the money to buy a high performance custom-made replacement. Last one lasted about 5 years and finally crapped out -- good for me, now bad for my budget: $370 ;)
Thanks a lot Lavolpe, I apreciate the cue. I'm reading the link you provide, I'm not sure I understand why the IDE would crash with that configuration.
I'll try to reproduce it to see if it apply, I'm not using the shell but if I can understand the reason why it does, it might give me a cue on my own problem.
I'll also investigate more by reproducing the problem with the AIC, for now I have simply removed the AIC reference from the project as it was not mandatory. (I had hoped to skin my project in a later version)
again your work is excellent and I always apreciate your input.
I'm glad you came back on the forum, I had posted some other bug in your absence but it is not really important. some were strange though (putting 2 AIC control over each other with transparency caused a race condition and the image became weird - zoomed in)
Do you still intend to produce a new version with DPI awareness ? I'm asking with sincere interest but I understand how busy our regular life keep us from doing everything we wish :)
wish you the best for your car... didn't know you were fan of antique :) I failed to translate the name of the part you are talking about, is it part of the carburator ? It is a wonderfull car... Wish I had one like that. I wouldn't mind if you post some picture of her online :D
thanks for all.
<<<When you get that message box, is it possible to break into the code to see what line is being executed? That would help.
Edit: When it happen, I can't even save the project (it raise the out of memory error), I got to exit the IDE and load back. fortunately, my setting are set to save project before every run. But the problem don't raise while running. It raise AFTER I hit STOP (while the program is on waiting) or when I EXIT the program and return to IDE
The control only draws itself under a few conditions: VB tells it to, user calls refresh, animation frame changed, user changes some drawing options or changes the assigned picture. For windowless controls, if 3 controls were overlapped with each other for example, a redrawing of one would trigger redrawing of all 3, where they intersect. VB clips the dirty area of the DC, sends control lowest in ZOrder a paint event, passes the repainted DC to the next in ZOrder, and so on. Once all have painted, VB updates the screen. As far as the effect you experienced, that would need to be troubleshot. Could be a logic error within the AIC. But in post #3 (1st page), twice I recommended not to overlap controls.
Yes, I thought I was nearly done with it, but after learning more about DPI awareness, I wasn't happy with the logic and will need to start fresh.
Dizzy = nickname for Distributor
Yes, that's what I opted in to fix the problem :) although, the problem (in my case) was not the primary redraw when the control overlap, but when I move the mouse over the control. Then, the image under the second control became zommed in... anyway, like you said... fixed by not overlapping :)
The other bugs was a scale bug where not all pixel get the proper color. (having a region completely white for some reason)
I wanted to ask you to take something into consideration... It is YOUR control, so the decision is yours... why not make the control in a way we can "remove" easyly part of it ? For example, let's say someone intend to use it only for PNG and JPG, if we could remove module we could compile a control easier to "debug/diagnose" under some condition.
While attempting to fix a bug by my own in past, I have attempted to unload the class related to other image format... the task reveal itself to be almost impossible because of the intresec interraction with one another... So I had this thought... but I understand it would require some work.
anyway... like I said... just a thought.
that's the cap with electrode spinning to give fire to candle in proper order right ?
I had this piece broken down on me on a Dodge 72
I will consider options where the user can customize the ocx before they compile it.
Yes. Though the order is always one way: clockwise or counter-clockwise. The cables from the cap to the engine result in the proper firing order if the cables applied properly.Quote:
that's the cap with electrode spinning to give fire to candle in proper order right ?
Hi Lavolpe,
I'm in a dead end with something, I hope you can help.
basiquely what I'm trying to do is:
Set pngLavolpe1.Picture = LoadPictureGDIplus(picVb6PictureBox.picture)
I received error 481, incorrect format.
I look at documentation from your component, didn't find anything unusual.
However, I found something that let me skeptical about eitheir or not your AIC can do this in that particular case.
When my program start, I got a white rectangle in the picturebox frim a file (BMP). Nothing fancy
on some subroutine, I do a
1. picturebox.cls
2. ... some modification with DrawText Api
3. picturebox.refresh
4. set picturebox.picture = picturebox.image
then I try:
Set pngLavolpe1.Picture = LoadPictureGDIplus(picturebox.picture)
tha'ts where it'S crashing with error 481.
Is there a way I can manipulate my image with DrawText and then put it back in AIC control ?
I'm using picturebox because AIC doesn'T expose hDc
picturebox.ScaleMode is 3 'Pixel
picturebox.AutoRedraw = True
Thanks for any input...
ps. glad you found your car part. :) hope you'll travel the road long before winter :)
Crashing should not be happening and I suspect it is due to not handling errors. If LoadPictureGDIplus fails, it generates an error. Use On Error statement before calling that function. Ok, that fixes any crashing.
Now regarding incorrect format error. That error only occurs if LoadPictureGDIplus. Long story short... When passing the Picture object, AIC tries to get VB to give it the image data via a stream. This obviously is a problem on some systems, based on previous posts. I've offered some possible tweaks in those previous posts, but not all may apply. One workaround that should work is to pass the handle, ie., Set pngLavolpe1.Picture = LoadPictureGDIplus(picturebox.picture.handle). Hopefully that gets past that error.
Regarding the AIC not exposing it's hDC. But it does through the WantPrePostEvents property and responding to the PostPaint (in your case). However, and this could be a problem, GDI+ should always be used to draw text. This is because the hDC passed in that event may be holding a 32bit image and DrawText/TextOut does not render correctly on 32bit bitmaps. The alpha channel can become invalid.
I'm still in developping phase... by crashing I meant not doing what we expect... throw error 481 instead of loading image...
sorry to have mislead you... I'm not handling error at this point.
I would be interested to read thoses post... although I don't think it's the issue here (some systems...) Never had ANY problem with your component except "some" minor glitch in rendering...
I'll try to find them. Do you remember some content to facilitate the search ?
instant fixe! thanks.
Thanks for the information. I'm writing directly onto a picturebox then passing the picture to the AIC control. It doesn'T need transparency, it's simply a BMP, then I save it to PNG or JPG, depending of the image.
The program I do simply put and order image in an Access Database for VR on sales, with the program, you can add, remove and manage the VR that are or not on sales... Then the program create Thumbnail and the resulting Access Database.
The result is displayed as a web page I have created in the form of a "book" where you can turn page, click thumbnail...
an image is worth 1000 words:
http://www.campingbaiedudiable.ca/roulottes_vendre.html