FW_SaveImage

FW_SaveImage

Postby Natter » Tue Feb 13, 2024 1:38 pm

Hi,

I create an image in A2 format.
Code: Select all  Expand view
hBmp :=FW_MakeYour Bitmap(7016, 4961, {|hDc|FW_DrawImage(),..})

Then I save it to file
Code: Select all  Expand view
FW_SaveImage(bmp, "myfile")
Everything is fine.

I create an image in A1 format.
Code: Select all  Expand view
hBmp:=FW_MakeYour Bitmap(9933, 7016, {|hDc|FW_DrawImage(),..})
When saving it to a file, the program terminates without an error. I understand that there is not enough memory. What can be predicted ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: FW_SaveImage

Postby nageswaragunupudi » Tue Feb 13, 2024 2:40 pm

When saving it to a file, the program terminates without an error. I understand that there is not enough memory.


Possible.
But I tried with the same size it is working for me quite well.
This is my sample program
Code: Select all  Expand view
function LargeBmp()

   local hBmp

   ? "start"

   hBmp  := FW_MakeYourBitmap(9933, 7016, <|hDc,w,h|
      local aBmp
      aBmp  := FW_ReadImage( nil, "..\bitmaps\sea.bmp", , .t. )
      FW_DrawImage( hDC, aBmp[ 1 ],              { 0, 0, 768*4, 1024*4, 1 } )
      FW_DrawImage( hDC, "..\bitmaps\olga1.jpg", { 0, 1024*4, 450*7, 1024*4 + 352*7, 1 } )
      FW_DrawImage( hDC, aBmp[ 1 ],              { 3200, 0, 3200+768*4, 1024*4, 1 } )
      FW_DrawImage( hDC, "..\bitmaps\olga1.jpg", { 3200, 1024*4, 3200+450*7, 1024*4 + 352*7, 1 } )
      PalBmpFree( aBmp )
      return nil
      > )

   ? hbmp

   FW_SaveImage( hBmp, "large.png" )
   DeleteObject( hBmp )

   ? "saved"

   XImage( "large.png" )

return nil


I am able to see the image well.
If you want I can also post a screenshot
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_SaveImage

Postby nageswaragunupudi » Thu Feb 15, 2024 12:51 am

Did you try my sample program?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_SaveImage

Postby Natter » Thu Feb 15, 2024 11:39 am

Yes, your example works well. But files in A1 and A0 format do not want to be saved from my program :cry:

I am trying to make an option with the creation of several bitmap files and their subsequent gluing.
Is it possible to split hBmp into several parts and save them as separate files ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: FW_SaveImage

Postby nageswaragunupudi » Thu Feb 15, 2024 3:22 pm

Yes, your example works well. But files in A1 and A0 format do not want to be saved from my program.


How can I help you?
Can you send me a test program of yours to my personal email?
nageswaragunupudi [at] gmail [dot] com
I am trying to make an option with the creation of several bitmap files and their subsequent gluing.

For gluing, you can use the function
Code: Select all  Expand view
FW_StitchImages( uImage1, uImage2, [cSide], [cType] ) --> newImage


uImage1 and uImage2: can be hBitmap or any image-file or any image-buffer of any type.
cSide: Can be "R" or "B". R for Right and B for bottom. Default Bottom
cType: If the parameter is nil, the result is hBitmap
if cType is "bmp", "jpg", "png" the result is an image buffer of the type speicified, which can be saved to a file directly wih MEMOWRIT
if cType is .T., then the result type is the type of the first image.

Is it possible to split hBmp into several parts and save them as separate files ?

Code: Select all  Expand view
FW_TransformBitmap( hBmp, aCrop ) --> hCroppedBmp
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_SaveImage

Postby Natter » Thu Feb 15, 2024 3:41 pm

Thank you, Rao, very interesting functions - FW_StitchImages and FW_TransformBitmap. I'll try with them
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: FW_SaveImage

Postby Natter » Fri Feb 16, 2024 9:29 am

I wanted to divide the hBmp into 3 parts - 33%, 33% and 34%
How can I do this using the FW_Transform Bitmap function ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: FW_SaveImage

Postby nageswaragunupudi » Fri Feb 16, 2024 3:46 pm

Try this sample which splits and again glues together
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local cSource  := "\fwh\bitmaps\sea.bmp"
   local aSave
   local hSource, aBmp
   local nWidth, nHeight, h, n, c, nTop, nBot
   local nParts   := 3

   hSource  := FW_ReadImage( nil, cSource )[ 1 ] // hBitmap
   nWidth   := GetBmpWidth(  hSource )
   nHeight  := GetBmpHeight( hSource )
   h        := Int( nHeight / nParts )

   nTop        := 0
   aBmp        := Array( nParts )

   for n := 1 to nParts
      nBot  := If( n == nParts, nHeight, nTop + h )
      aBmp[ n ]   := FW_TransformBitmap( hSource, { nTop, 0, nBot, nWidth } )
      nTop  := nBot
   next

   DeleteObject( hSource )

   // SaveAs png files
   aSave    := Array( nParts )
   for n := 1 to nParts
      aSave[ n ] := BeforAtNum( ".", cSource ) + cValToStr( n ) + ".png"
      FW_SaveImage( aBmp[ n ], aSave[ n ] )
      DeleteObject( aBmp[ n ] )
   next

   // View all the saved parts
   xbrowser aSave SETUP ( ;
      oBrw:aCols[ 1 ]:cDataType := "F", ;
      oBrw:nMarqueeStyle := 0 )

   // Let us now glue all the parts and view the reconstructed full image

   c  := aSave[ 1 ]
   for n := 2 to nParts
      c  := FW_StitchImages( c, aSave[ n ], , "png" )
   next

   // save the glued image to file
   MEMOWRIT( "new.png", c )
   XImage( "new.png" )

return aSave
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_SaveImage

Postby Natter » Fri Feb 16, 2024 4:31 pm

I think the problem is not saving large formats through the FW_SaveImage function.

To get a larger format, I expanded the dialog box to the desired size (oDld:Move()). Further, moving this dialog according to the specified algorithm, I received the device context of the screen. It used to work, now it doesn't.
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 89 guests