Recent

Author Topic: another bug?  (Read 6351 times)

cd

  • Jr. Member
  • **
  • Posts: 54
another bug?
« on: April 28, 2012, 02:04:57 am »
this code doesn't draw anithing:
Code: [Select]
  bmp:=createImageFunction(); // 640x480
  bmp.AlphaFill(0);
  bmp2 := bmp.Resample(240,180,rmSimpleStretch);
  bmp.AlphaFill(255);
  image.PutImage(0,0,bmp2,dmSet);
while this code draws:
Code: [Select]
  bmp:=createImageFunction(); // 640x480
//  bmp.AlphaFill(0);
  bmp2 := bmp.Resample(240,180,rmSimpleStretch);
//  bmp.AlphaFill(255);
  image.PutImage(0,0,bmp2,dmSet);

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: another bug?
« Reply #1 on: April 28, 2012, 09:40:38 am »
This is normal.

In your the first code, you get bmp2 filled with alpha = 0, so when you draw it, nothing happens.

When you do Resample, there is no link between the two bitmaps after the resampled bitmap is built.
Conscience is the debugger of the mind

cd

  • Jr. Member
  • **
  • Posts: 54
Re: another bug?
« Reply #2 on: May 08, 2012, 12:42:34 am »
ok, i see.
I should have guessed that myself.

another thing:
Code: [Select]
image.Draw(Canvas,R,True);seems to not work correctly - garbage output - with rect R twice smaller than the original image.

while
Code: [Select]
image.Draw(Canvas,R,False);works fine.

i don't need transparency here, i'd prefer the faster way: the first one with opaque=true should be faster i think, shouldn't it?

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: another bug?
« Reply #3 on: May 09, 2012, 07:05:19 pm »
Yes, opaque is supposed to be slightly faster, when an appropriate system function is available.

On which operating system (windows, linux, qt) are you trying to stretchdraw ?
« Last Edit: May 09, 2012, 07:07:54 pm by circular »
Conscience is the debugger of the mind

cd

  • Jr. Member
  • **
  • Posts: 54
Re: another bug?
« Reply #4 on: May 09, 2012, 07:42:13 pm »
linux gtk

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: another bug?
« Reply #5 on: May 09, 2012, 09:40:18 pm »
Try to replace the following line (line 242 in TBGRAGtkBitmap.DataDrawOpaque in bgragtkbitmap.pas) :
Code: [Select]
DataDrawOpaque(ACanvas,Rect,AData,stretched.LineOrder,stretched.Width,stretched.Height);By :
Code: [Select]
DataDrawOpaque(ACanvas,Rect,stretched.Data,stretched.LineOrder,stretched.Width,stretched.Height);
Conscience is the debugger of the mind

cd

  • Jr. Member
  • **
  • Posts: 54
Re: another bug?
« Reply #6 on: May 10, 2012, 11:40:00 pm »
i have not yet tried the fix you proposed.

for now i have another strange (as i believe) behavior:

Code: [Select]
// preparation
  tex:=TBGRABitmap.Create('image.png');
  tex_mask:=TBGRABitmap.Create('image.png');
  tex_mask.AlphaToGrayscale;

// fade in or out (called by timer with increasing/decreasing value of c)
  tex.AlphaFill(255);
  tex.ApplyMask(tex_mask);
  tex.ApplyGlobalOpacity(c);

this code is used to fade out the image (c=255..0) and then to fade in (c=0..255). fade out is just fine, but after c=0 is applied as global opacity the images fades in with no color - just black instead of all ither colors. if i don't fade out down to c=0 opacity (say c=255..1), then the color is not affected.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: another bug?
« Reply #7 on: May 16, 2012, 08:36:16 pm »
It's normal, because when opacity is zero, it is considered as a transparent pixel, which has BGRAPixelTransparent value, i.e. r=g=b=a=0
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018