Forum > Graphics

Works on Win32 but not on WinCE.

(1/2) > >>

dan59314:
Hi,

   I am trying to get equivalnet of TBitmap.Scanline[0] by using TLazIntfImage,
   and draw FBmp1 on FBmp2 in a specified scale within FRasView record.
   
   The following code works fine on Win32, But has problem on WinCE.
   
   Win32 Shows the correct image http://dan59314.myweb.hinet.net/Image2.jpg
   
   
   In WinCE,
   
      When I load a pf8Bit *.bmp file and paint, programe didn't halt, but The result is incorrect http://dan59314.myweb.hinet.net/Image1.jpg
   
   
      When I load a pf24Bit *.bmp file and paint, programe halt and exit while calling RastPainter.PaintRGB24(),
      not even enter the function RastPainter.PaintRGB24().
      
   
   Can anyone tell me what's going wrong with WinCE coding....
   
   

--- Code: ---FBmp1, FBmp2 are TBitmap, have data, not empty
......

var
  FLazImage1, FLazImage2 : TLazIntfImage;  // Create and Free in FormCreate() and FormDestroy()

......

Paintfunction bellow........
 
  try
   FLazImage1.LoadFromBitmap(FBmp1.Handle,FBmp1.MaskHandle);
   FLazImage2.LoadFromBitmap(FBmp2.Handle,FBmp2.MaskHandle);             
 
 
   case FBmp1.PixelFormat of
   pf8Bit:
     begin
       strideBytes1 := RastPainter.BytesPerScanline(FBmp1.Width, 8, 32);
  strideBytes2 := RastPainter.BytesPerScanline(FBmp2.Width, 8, 32);

  FBmp1Scan0 := Pointer(FLazCnvImage.PixelData);
  FBmp2Scan0 := Pointer(FLazImage.PixelData);
       // this function paint FBmp1Scan0 into FBmp2Scan0 ----------------------
       RastPainter.PaintRGB8(FRasView, FBmp2Scan0, strideBytes2, FBmp2.Width, FBmp2.Height,
            FBmp1Scan0, strideBytes1, FBmp1.Width, FBmp1.Height, true);     
     end;   
   pf24Bit:
     begin
       strideBytes1 := RastPainter.BytesPerScanline(FBmp1.Width, 24, 32);
  strideBytes2 := RastPainter.BytesPerScanline(FBmp2.Width, 24, 32);

  FBmp1Scan0 := Pointer(FLazCnvImage.PixelData);
  FBmp2Scan0 := Pointer(FLazImage.PixelData);
       // this function paint FBmp1Scan0 into FBmp2Scan0 ----------------------
       RastPainter.PaintRGB24(FRasView, FBmp2Scan0, strideBytes2, FBmp2.Width, FBmp2.Height,
            FBmp1Scan0, strideBytes1, FBmp1.Width, FBmp1.Height, true);     
     end;     
   end;
           
  finally
 
  FBmp2.LoadFromIntfImage(FLazCnvImage);
  end;
 
--- End code ---
   
   
   
 
           
  // RastPainter.PaintRGB24(const aView:TRastViewRec;
  //    const CnvScan0:Pointer; cnvstrideBytes:integer; CnvWidth, CnvHeight:integer;
  //    Const ImgScan0:Pointer; ImgstrideBytes:integer; ImgWidth, ImgHeight:integer;
  //    blDIBUpWard:LongBool=true); 
  //

Marc:
in you example you have FLazImage1 and FLazImage2, but when accessing the data you use FLazImage
--- Code: ---FBmp2Scan0 := Pointer(FLazImage.PixelData);
--- End code ---

BTW, you don't need to get the LazImage data through LoadFromBitmap anymore (using LoadFromBitmap results in an image in pfDevice depth and might loose alpha info).
TBitmap (or any descendant of TRaserImage) has a RawImage: TRawImage property. Here you have directly access to the pixel data.

dan59314:

--- Quote from: Marc on October 06, 2009, 11:41:45 am ---TBitmap (or any descendant of TRaserImage) has a RawImage: TRawImage property. Here you have directly access to the pixel data.

--- End quote ---

Hi, Marc,

  Thanks for the reply.

In Win32,

  Yes, I did use TBitmap.RawImage originally,  I can mostly paint from FBmp1 to FBmp2 without problem, but sometimes it didn't paint. Don't know why?

  Also I need to draw FBmp2 to TPaintBox. If I use TLazIntfImage -> FBmp2, I can use BitBlt(PaintBox1.Canvas.Handle, 0,0, FBmp2.Width, FBmp2.Height, FBmp2.Canvas.Handle, 0,0 srcCopy) to show FBmp2 on TPaintbox without problem.  But never success if I use FBmp2.RawImage.


   Briefly,

   1.  With FBmp1.RawImage, FBmp2.RawImage, I can mostly draw FBmp1 on FBmp2, but not all the time.

   2.  I can't draw FBmp2 on TPaintBox by using
     BitBlt(PaintBox1.Canvas.Handle, 0,0,FBmp2.Width, FBmp2.Height, FBmp2.Handle,0,0,SrcCopy);

     neither   PaintBox1.Canvas.Draw(0,0, FBmp2); 

In WinCE,
   So far, never successed.


Daniel

Marc:
Did you use the Begin/EndUpdate when modifying the rawimage data ?
Did you check the "pixelformat" of the rawimage on CE ?

dan59314:

--- Quote from: Marc on October 07, 2009, 12:31:50 pm ---Did you use the Begin/EndUpdate when modifying the rawimage data ?
Did you check the "pixelformat" of the rawimage on CE ?

--- End quote ---

I tried BeginUpdate(true)  and EndUpdate(true), but nothing changed, can't BitBlt() FBmp2 on TPaintBox, either Win32 or WinCE.

Might somewhere I missed, I will tried them again. May you post souce code how to use them?
And the pixelformat? Is there any limitation for WinCE?

Acutally I worked it out both on Win32 and WinCE in another way, but the efficiency is not good.

I found if I assign FBmp2.Width with different value everytime before painting. It will works to BitBlt() FBmp2 on TPaintBox.

Then I traced into the TPaintBox.SetWidth(), It seems to free data and re-allocate memory again.

I guess that's why the efficiency is worse. If so, is there any way that I can do?


Thanks again,

Regards,

Daniel

Navigation

[0] Message Index

[#] Next page

Go to full version