New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Glitch when resizing TBitmap #30
Comments
The following looks fine to me, though I don't really understand why you're bothering with both TImage32 and TBitmap.
|
Hi Angus, First of all, thank you for your answer :-) I tested your code and have the same issue than described. So I created a full example to make it easier to test on your side. https://github.com/Escain/TestImage32 Please, don't look to closely my code style, it's just a quick-dirty example. |
When you have the sorts of problems you're having now, it's important to simplify the steps as much as possible, so you don't assume the issue is in one particular area. And that's why I posted the code above, since I strongly suspect your problem is elsewhere. And I'm busy with other things so, rather than me debugging this for you, I suggest you do the following: |
The images saved by your code also look bad. |
I just used the PNG image that you provided.
|
Hi Angus, Thank you for your answer. The background of your "X"/Close png is white, I suppose that (considering that the glitch is white), the issue is not visible. The image that I provided is the "Original size" rendering, not the original image with transparency. You can find a fully (non)working example in the test that I provided. Have a good day. |
No it's not. I presume whatever app you're using to view this image has a default white background. Change the default transparency background to another color. Alternatively, click on this "X" image above and it'll display the image in a new tab window (which in Chrome at least is usually black). Anyhow, I've spent more than enough time on this now. Sorry I can't help further. |
Hi Angus, I understand that you don't have lot of time, actually I also have little time. But I assume this is the place to report bugs, and the fact that we have little time does not make my research less worthy or this bug to not exist.
So I went with your example and I am unable to use
This returns the following images: Which indeed have the issue. Consequently, both images: represented to screen AND saved to file have the same problem, but only after resizing. And only on Delphi (not on Lazarus). I asked a few colleagues to test my example on their computer in case I have something weird. I will update in case we discover something. |
Hi Angus, So I could effectively reproduce your code and I made this following modification to show BOTH: working and not-working cases:
Note: the bottom-left case, using |
You're right, in a sense it is faulty! 😱
So mostly mea culpa, and thank you for your patience and persistence. Edit 1:
white1.png: Edit 2:
|
I've just updated TImage32.CopyToBitmap() again in the repository so that it will now blend copy TImage32 onto the bitmap (instead of replacing the bitmap's image). Now the user will have complete control over the bitmap's size and background. Lines 259 to 260 in 9fc9caa
|
Hi Angus, That is fantastic that you already got one of the two functions solved. Images now looks good in our GUI :-) I totally agree: when making software, we usually have to deal with workaround for bugs that are in third-party libraries that we include, like the TBitmap that are not fully compatible with transparency. In our case, we are using Image32 exactly due to that: TBitmap resizing (StretchDraw) is not compatible with transparency. If you want to keep the previous functionality, here is something that seems to work (Not heavily tested). However your version seems more versatile.
|
I'm commenting on this rather old thread to acknowledge that there was also a bug in TImage32.CopyToBitmap (which I've just fixed). When saving images with no transparency, they were being saved to stream as 24bpp images though incorrectly using bitfields. Apparently only 16bpp and 32bpp should use BI_BITFIELDS, though most software just ignores bitfields when loading 24bpp images. |
Hello,
I am trying to use Image32 to scale images in our application. After integrating the library, I am facing some glitches on the resulting TBitmap with transparency.
The full question is described here: https://stackoverflow.com/questions/76818048/resizing-tbitmap-with-alpha-channel-in-delphi
Simplified, the code looks like :
We have to interact with other components, that is why we use TBitmap and not TImage32 as the result.
The resulting image is scaled correctly, but alpha channel seems incorrect:
Original:
Scaled:
The text was updated successfully, but these errors were encountered: