Recent

Author Topic: Building a composite image  (Read 4779 times)

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #30 on: June 12, 2022, 11:23:50 pm »
...However, and with apologies to OP for wandering off-topic,
No need for any apology Mark - I've often been guilty of thread drift :)

Quote from: MarkMLl
...it's interesting to compare the situation in the 2000s, when we had a dichotomy between object-editing and pixel-editing software (Corel vs Photoshop)...
I would dis-agree that there is any conflict of interest (if that is what you are suggesting) between CorelDRAW! & Photoshop  - - - they are different tools and I use both according to the job in hand.

As noted by Winni, CorelPaint was never a contender for bitmap editing if you had Photoshop.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Building a composite image
« Reply #31 on: June 12, 2022, 11:29:23 pm »
As noted by Winni, CorelPaint was never a contender for bitmap editing if you had Photoshop.

And the Photoshop was never a contender if you had the Gimp!!!


MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Building a composite image
« Reply #32 on: June 12, 2022, 11:41:27 pm »
My very first step in graphical editing I did with the fast and lightweight PhytoStyler. After 2 versions it was bought by Adobe and vanished to nowhere. Now it is Open Source somewhere in the net.

My first steps were DR-Draw vs DR-Paint, and even then I felt that there was a tension between the two approaches.

Even 35 years ago, when I was selling software, there was a dichotomy between the very small number of "CAD-like" vector programs and "paint-like" painting programs... and that 2-D era persisted in popular culture until comparatively recently. I specifically remember one program which manipulated a low (spatial) resolution image with an unreasonable number of pixels per bit: the results looked good, so it sold well.

But in the present day, and focussing on free software: things like Blender and Fusion 360 are remarkably competent, but there's still a distinction to be made between defining an object (in a way that allows it t be rescaled etc.) and tweaking something which is about to be sent to a fabrication device.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Building a composite image
« Reply #33 on: June 13, 2022, 12:16:45 am »
I would dis-agree that there is any conflict of interest (if that is what you are suggesting) between CorelDRAW! & Photoshop  - - - they are different tools and I use both according to the job in hand.

The problem is that hoi polloi- including those I've worked for- can't "get their head around" the distinction between manipulating (e.g. in two dimentions) a rectangle or (e.g. in three dimensions) a cube and manipulating a projection onto a bitmap of adequate resolution.

I suspect that there are still a lot of people who appear to be doing good work in the 3D community but who are really arbitrarily painting surfaces or volumes with arbitrary pixels rather than looking at the surfaces that they are trying to represent.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #34 on: June 13, 2022, 02:37:34 am »
I'm now confused  :o %)   Not by thread-drift . . .  though I am now getting back to the original question.

It occured to me that I ought to be able to meld the two things I've learned over this weekend -
1 - How to create a transparent bitmap with a fixed size centre hole and dynamic OD
2 - How to create a polygon simulating a dynamic gear.

It seemed reasonable to simply create the first which would provide the general appearance of a gear and then lay the second on top to add the teeth.

It hadn't occured to me that a polygon would be filled so I was somewhat disheartened to discover that the bitmap image no longer appeared. I thought that it may be because I'd made the TImage filled with clWhite so changed that to clNone (without success).  Following the methodology of making the bitmap transparent I then used similar code to make the polygon transparent. - - - - - -   This then became rendered as Black :(

I must surely be missing some 'trick' which will allow me to place one transparent image on top of another?
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Building a composite image
« Reply #35 on: June 13, 2022, 10:32:56 am »
Hi!

Red contour with tansparent fill:

Code: Pascal  [Select][+][-]
  1. BGRA.DrawPolygonAntialias(poly,cssred,2,BGRAPixelTransparent);

Winni

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #36 on: June 13, 2022, 11:45:58 am »
Red contour with tansparent fill:

Code: Pascal  [Select][+][-]
  1. BGRA.DrawPolygonAntialias(poly,cssred,2,BGRAPixelTransparent);
Hi Winni,

I'd looked for such an option in the BGRADefaultBitmap Unit but hadn't seen any reference to Transparent  except for the notes "The stroke is stricly over the fill even if partially transparent. "

Your suggetion prompted me to make sure that the WHOLE poly was transparent - having just the FILL transparent wouldn't be good enough so I added the BGRAPixelTransparent to Image.Canvas.Brush.Color as well.

I had already added a 'shape' in the form of a Red rectangle in the background so that it would prove that the transparency was in fact working . . . . . .   Regrettably - abject failure!

In the interests of providing as much information as posible to enable reasoned judgement, I've attached a .ZIP file of the latest version of the project.  You'll notice that I have added the [Speed] option that I referenced earlier - and it works, limited but the principle is proved.


D'oh!  [EDIT]   to add .zip !!

« Last Edit: June 13, 2022, 12:14:18 pm by J-G »
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #37 on: June 13, 2022, 02:50:43 pm »
'Clipping' solved !!    -   I had been changing the size of the wrong 'Image' - I've now correctly identified the correct variable and made it 4px larger also adjusting the half-width & height to compensate for the Centre being 'shifted' 2px.

As Winni suggested,  " add one to the size"  -  but it has to be the the right 'size'  :-[
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #38 on: June 16, 2022, 11:17:09 am »
Red contour with tansparent fill:
Code: Pascal  [Select][+][-]
  1. BGRA.DrawPolygonAntialias(poly,cssred,2,BGRAPixelTransparent);
Can anyone else suggest why Winni's suggestion doesn't create a transparent outline which can be shown on top of a TBGRABitmap ?
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Building a composite image
« Reply #39 on: June 16, 2022, 03:29:45 pm »
Red contour with tansparent fill:
Code: Pascal  [Select][+][-]
  1. BGRA.DrawPolygonAntialias(poly,cssred,2,BGRAPixelTransparent);
Can anyone else suggest why Winni's suggestion doesn't create a transparent outline which can be shown on top of a TBGRABitmap ?

Yes it is transparent. The thing is you set the background to white, try drawing a picture in the background and you will see that the gears are transparent.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #40 on: June 16, 2022, 04:46:39 pm »
Yes it is transparent. The thing is you set the background to white, try drawing a picture in the background and you will see that the gears are transparent.

You must have missed my comments about putting a 'shape' in the background to check this Lainz - - - but thanks for your input.

The background is not set to White either - and just to be 100% sure I have checked the Object Inspector and made sure the T_Img has 'Transparent' = True - this is also done in code :
Code: Pascal  [Select][+][-]
  1.   with T_Img do
  2.     begin
  3.      Canvas.Brush.color := BGRAPixelTransparent;    // clWhite
  4.      Canvas.Fillrect(0,0,T_Img.width, T_Img.height);
  5. {
  6.      Picture.Clear;
  7.      Picture.Bitmap.SetSize(T_Img.width, T_Img.height);
  8.      Picture.Bitmap.TransparentColor:=clWhite;
  9. }
  10.      Transparent:=True;
  11.     end;
  12.  

If I include the lines commented out, then I get a black background.

I've taken a ScreenGrab showing the Form as designed with the 'shape' clearly shown across the centre (ish) with the running program to the left - quite clearly showing that the T_Img obliterates the 'shape'.   Further, I have also tried setting the colour to clWhite AND removing the comments - this also shows 'black'.

In the event that a 'Shape' is not acceptable in the background (and I cannot see why not) I've added a TImage into which I've loaded a .PGN file of a Gear - again I've attached a ScreenGrab.

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Building a composite image
« Reply #41 on: June 16, 2022, 05:30:53 pm »
Why you're using an image instead of drawing with BGRABitmap? You're mixing things..

Try loading a file with BGRABitmap, draw it first to the canvas and then draw the gear.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Building a composite image
« Reply #42 on: June 16, 2022, 05:38:54 pm »
Why you're using an image instead of drawing with BGRABitmap? You're mixing things..

Try loading a file with BGRABitmap, draw it first to the canvas and then draw the gear.

That is exactly what I will do in the full program. The only reason I'm trying to do this in the 'test' program is that I found that it didn't work when I added the poly-drawing code to the full program.

Surely, if a generated image is transparent it shouldn't matter what type of object is in the backbround, it must be visible?

FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Building a composite image
« Reply #43 on: June 16, 2022, 05:57:49 pm »
Why you're using an image instead of drawing with BGRABitmap? You're mixing things..

Try loading a file with BGRABitmap, draw it first to the canvas and then draw the gear.

That is exactly what I will do in the full program. The only reason I'm trying to do this in the 'test' program is that I found that it didn't work when I added the poly-drawing code to the full program.

Surely, if a generated image is transparent it shouldn't matter what type of object is in the backbround, it must be visible?

Well if it doesn't works surelly not  ::)

Try with BGRABitmap, or tell me in the code where you need the image and I'll add it.

paweld

  • Hero Member
  • *****
  • Posts: 999
Re: Building a composite image
« Reply #44 on: June 16, 2022, 05:58:21 pm »
In Gears procedure set:
Code: Pascal  [Select][+][-]
  1.   ms := TMemoryStream.Create;  //declare in var section
  2.   tmp.SaveToStreamAsPng(ms);
  3.   ms.Position := 0;
  4.   T_img.Picture.LoadFromStream(ms);
  5.   ms.Free;
Instead of:
Code: Pascal  [Select][+][-]
  1. tmp.Draw(T_img.Canvas, 0, 0, False);
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018