- This topic has 20 replies, 2 voices, and was last updated 9 years, 11 months ago by SzakiLaci.
-
AuthorPosts
-
September 16, 2014 at 1:43 pm #36290SzakiLaciParticipant
Hi,
Sorry, but I'm trying to solve that since 3 days and have no luck. Please help me:
How can I copy a part of the original image loaded into TsImage ? (keeping 32bit alpha channel too)
The result is always a full white empty bitmap, not the picture I want to “cut out” 🙁
Tried these:
Code:partPic:= CreateBmp32(ew, eh);
img1.Picture.Bitmap.Canvas.CopyRect(Rect(0,0, ew, eh), PartPic.Canvas ,
Rect(spe_left.Value, spe_up.Value, spe_right.Value, spe_down.Value));or
Code:BitBlt(kivagas.Handle, 0,0, ew, eh,
img1.Picture.Bitmap.Handle, spe_ball.Value, spe_fent.Value, SRCCOPY );…
it seems to me, that img1.Picture.Bitmap is not holding the uncompressed picture of the JPG or PNG.
Is there no way, to 'get out' the uncompressed version?
September 16, 2014 at 3:50 pm #52461SupportKeymasterHello
I not quite understand a question, seems.
This image is stored in the ImageList?
Or you want to receive a bitmap which contained in “img1.Picture.Bitmap”?
September 17, 2014 at 12:39 am #52463SzakiLaciParticipant'Support' wrote:This image is stored in the ImageList?
Or you want to receive a bitmap which contained in “img1.Picture.Bitmap”?
No, it's not stored anywhere. I'm trying to write a kind of “picture editor/cutter/resizer”.
1. I load a JPG or PNG runtime directly into a TsImage
(Because it can load many types well, and keep 32bit alpha too)
2. Than I set borders to cut (and keep a part of the pic)
3. Than will re-compress as a smaller PNG, and save to a Database.
Thanks !
September 27, 2014 at 8:29 am #48844SupportKeymasterSo, you need to compress a small image into Png? It's not possible with acPNG handler.
September 30, 2014 at 9:23 am #52519SzakiLaciParticipant'Support' wrote:So, you need to compress a small image into Png? It's not possible with acPNG handler.
This was NOT my question!
(I can compress images with 2 different units, like SynGDIPlus mentioned here… So it's working fine.)
My question was:
“How can I copy a part of the original image loaded into TsImage”
______________________
I've tested the problem further, used different units to load the image … (leaving TsImage out)
and realized it works fine, if I define the destination Bitmap as 24bit. The problem starts, if I use pf32bit, or the predefined CreateBmp32(ew, eh); function.
Seems for me like Delphi 7 CopyRect is buggy, if trying to work with alpha-channel bitmaps.
September 30, 2014 at 9:31 am #52520SzakiLaciParticipant'SzakiLaci' wrote:Seems for me like Delphi 7 CopyRect is buggy, if trying to work with alpha-channel bitmaps.
.. OR :
maybe copy works fine, BUT when I load the 32bit alpha-channeled Bitmap back to the TsImage >> it can not show ?
(I have red, that TImage can not handle 32bit bitmaps. Can TsImage do that?)
But newer Delphi should be able to handle it… :
So I'm officially confused now :wacko:
September 30, 2014 at 4:37 pm #52523SupportKeymasterHi
You tried BitBlt procedure?
October 24, 2014 at 8:05 pm #52679SzakiLaciParticipantFew things sorted out. (resize)
1. It is NOT recommended to use TsImage.Loadfromfile … (it can not load BMP files ! and many other formats 🙁 )
2. So instead I'm using TSynPicture … for manipulating + converting to BMP >> and Assign the final (resized) picture to a TsImage later.
3. But I still 2 big problems:
3.1 Somehow I loose alpha channel, when I load 32bit PNG and than convert to BMP and stretch it.
– if loaded directly >> no alpha shown
– if loaded with tSynPicture > and Assigned() >> still no sign of transparency
(tried both Transparency property set to True or False)
… I guess because it is still using the inherited methods of a normal TImage.
3.2 I'm using now your AC stretching code:
sGraphUtils.Stretch(cutOutBmp, TempBmp, sw, sh, ftMitchell, 2);
But it becomes FUZZY ! (looks more ugly than a simple Canvas.StretchDraw() )
(See attached 2th picture from close… )
WHY?
[attachment=6939:original.jpg]
[attachment=6940:stretched.png]
November 3, 2014 at 11:50 am #52697SupportKeymasterHello
What purpose of this component in your application?
You uses it for converting of images?
November 8, 2014 at 7:20 pm #52711SzakiLaciParticipantStill no success 🙁
Tried to install Graphics32 component pack to do the RESIZE part. It Destroyed my whole program by deleting ALL pictures saved in TImages from the *.dfm files 😡
It would be a really really big help, if YOU could write 1 line how to resize a picture nicely using your component ? :wub:
(Theoretically it SHOULD work, because your component shows pictures on top of components very beautifully … so why isn't this working direktly? :
Code:sGraphUtils.Stretch(cutOutBmp, TempBmp, sw, sh, ftMitchell, 2);November 8, 2014 at 7:40 pm #52712SzakiLaciParticipant'Support' wrote:Hello
What purpose of this component in your application?
You uses it for converting of images?
I don't really understand, how is it relevant, but …
This form will be a multi-purpose module:
– picture selector / by keyword-search, etc…
– picture-database uploader = DB, downloader = HTTP, syncronizer = HTTP + DB-DB + filesys …!
– editor (before uploading different size/purpose/type files > needs to be “standardized” / categorized)
– should adapt for different size & different resolution. (from 800×480 – to – FULLHD+ )
… attaching some pictures.
November 10, 2014 at 12:45 pm #52714SupportKeymasterHi!
You can try not only ftMitchell, but other modes also in the Stretch procedure.
You tried other options?
November 11, 2014 at 7:16 am #52720SzakiLaciParticipant'Support' wrote:Hi!
You can try not only ftMitchell, but other modes also in the Stretch procedure.
You tried other options?
No, I did not try yet, because wanted to use the BEST quality method. Will try it today and report back.
November 11, 2014 at 7:23 am #52722SupportKeymasterThis option can change an algorithm of resizing and quality is different for different algorithmes.
November 15, 2014 at 5:21 pm #52734SzakiLaciParticipant'Support' wrote:This option can change an algorithm of resizing and quality is different for different algorithms.
Sorry for the late response. Tried Lanczos3 too. Same ( fuzzy ) results.
Had an interesting phone call today. An other (of your costumer) AC user reported me too:
– had tried to install Graphics32 component pack, and deleted all pictures stored in TImage components for him too.
Can you please try to install Graphics32 too? Put a simple bmp into a simple TImage (NOT TsImage), and see if it's beeing deleted after that.
SAVE your work in a different (ZIPed) location. I usually save the whole borland directory…
November 17, 2014 at 6:20 am #52750SupportKeymasterMaybe you can give me an example which I can try?
I'll check Graphics32 soon.
November 25, 2014 at 12:19 pm #52801SzakiLaciParticipant'Support' wrote:Maybe you can give me an example which I can try?
I'll check Graphics32 soon.
Graphics32 is COOL ! 🙂
Yesterday night I've successfully did what I wanted to with it. (Resize nicely)
Solution was here:
http://stackoverflow.com/questions/1976116/scale-an-image-nicely-in-delphi
November 26, 2014 at 5:29 am #52810SzakiLaciParticipantI was happy too soon when I thought I finished 🙁
TsImage is showing NO 32 bit BMP pictures under win7 64 bit, if loaded directly into it. (Under XP everything seems to be fine.)
Have to test more … Agggghhhh 🙁 Hate to through away 3 month of work and start from the beginning because a component isn't working as it should 🙁 🙁 🙁
(Compiled with Delphi7)
November 26, 2014 at 7:41 am #52812SupportKeymasterHi!
Maybe you can show a demo with the problem?
I can help better in this case…
November 27, 2014 at 1:08 pm #52825SzakiLaciParticipant'Support' wrote:Hi!
Maybe you can show a demo with the problem?
I can help better in this case…
Sadly can not “cut out” part of the source code from the whole program and make a working Demo from it. It would take as much time as rewriting the whole module to an other component. (GR32 TImage32 )
Sending just a screenshoot won't help you to find the bug at the component.
Thanks for trying to help… :wub:
-
AuthorPosts
- You must be logged in to reply to this topic.