Gradient Colors

Gradient Colors

Postby Natter » Sat Aug 31, 2024 5:02 pm

Hi,

There is a .png file - a gradient of some color (for example, red)
https://cloud.mail.ru/public/NipP/v5trqrynQ

Is it possible to get a list of colors from this file (from left to right) ?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Gradient Colors

Postby karinha » Sun Sep 01, 2024 3:06 pm

Maybe,

https://encycolorpedia.pt/ff0000

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Gradient Colors

Postby Natter » Sun Sep 01, 2024 6:30 pm

I've seen it all. But I haven't figured out how to use it. The only thing that comes to mind is to open bitmap's gradients in XImage and read the pixel colors from DC. Save the results to the database :shock:
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Gradient Colors

Postby nageswaragunupudi » Mon Sep 02, 2024 4:50 am

Code: Select all  Expand view  RUN
function ImagePixels()

   local hBmp  := FW_ReadImage( nil, "https://thumb.cloud.mail.ru/weblink/thumb/xw1/NipP/v5trqrynQ" )[ 1 ]
   local aClrs

   aClrs := ReadBmpPixels( hBmp )
   DeleteObject( hBmp )

   XBROWSER aClrs SHOW SLNUM

return nil

static function ReadBmpPixels( hBmp )

   local hBmpOld, hDC0, hDC
   local nBmpWidth  := nBmpWidth( hBmp )
   local nBmpHeight := nBmpHeight( hBmp )
   local nRow, nCol, nClr, aCol
   local aClrs := {}

   hDC0     := GetDC(  0 )
   hDC      := CreateCompatibleDC( HDC0 )
   hBmpOld  := SelectObject( hDC, hBmp )

   nRow     := 3 // can be any
   AAdd( aClrs,  aCol := { 1, 1, nClr := GetPixel( hDC, 1, 1 ), cClrToCode( nClr ) } )
   for nCol := 2 to nBmpWidth - 1
      nClr     := GetPixel( hDC, nCol, nRow )
      if nClr == aCol[ 3 ]
         aCol[ 2 ] := nCol
      else
         aCol  := { nCol, nCol, nClr, cClrToCode( nClr ) }
         AAdd( aClrs, aCol )
      endif
   next nCol

   SelectObject( hDC, hBmpOld )
   Deletedc( hdc )
   ReleaseDC( 0, hDC0 )

return aClrs
Regards

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

Re: Gradient Colors

Postby Natter » Mon Sep 02, 2024 7:21 am

Thank you, Rao!
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Gradient Colors

Postby Jimmy » Mon Sep 02, 2024 2:34 pm

hi,
i got this Error
Imgpixel.prg(9) Error E0030 Syntax error "syntax error at 'ACLRS'"

what i´m doing wrong :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Gradient Colors

Postby karinha » Mon Sep 02, 2024 2:43 pm

Jimmy wrote:hi,
i got this Error
Imgpixel.prg(9) Error E0030 Syntax error "syntax error at 'ACLRS'"

what i´m doing wrong :?:


Code: Select all  Expand view  RUN

#include "FiveWin.ch"
 



Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Gradient Colors

Postby karinha » Mon Sep 02, 2024 3:07 pm

Master Nages, how do I record in a .TXT or .DBF?

Maestro Nages, ¿cómo grabo en un .TXT o .DBF?

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Gradient Colors

Postby nageswaragunupudi » Mon Sep 02, 2024 6:29 pm

Are you asking how to store an array as text in a txt file or dbf?

Code: Select all  Expand view  RUN
MEMOWRIT( cFileTxt, FW_ValToExp( aAnyArrayData ) )
// later
cText := MEMOREAD( cFileTxt )
aArray := &c   // or &(c)
Regards

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

Re: Gradient Colors

Postby karinha » Mon Sep 02, 2024 7:06 pm

Thanks/Gracias Master Nages.

Code: Select all  Expand view  RUN

#include "FiveWin.ch"

FUNCTION ImagePixels()

   LOCAL hBmp := FW_ReadImage( NIL, "https://thumb.cloud.mail.ru/weblink/thumb/xw1/NipP/v5trqrynQ" )[ 1 ]
   LOCAL aClrs, cFileTxt := "NAGES.TXT", cTxt, cText

   aClrs := ReadBmpPixels( hBmp )

   DeleteObject( hBmp )

   XBROWSER aClrs SHOW SLNUM

   cTxt := {aClrs}

   MEMOWRIT( cFileTxt, FW_ValToExp( cTxt ) )

   WinExec( "Notepad.exe " + cFileTxt )

RETURN NIL

STATIC FUNCTION ReadBmpPixels( hBmp )

   LOCAL hBmpOld, hDC0, hDC
   LOCAL nBmpWidth  := nBmpWidth( hBmp )
   LOCAL nBmpHeight := nBmpHeight( hBmp )
   LOCAL nRow, nCol, nClr, aCol
   LOCAL aClrs := {}

   hDC0    := GetDC(  0 )
   hDC     := CreateCompatibleDC( HDC0 )
   hBmpOld := SelectObject( hDC, hBmp )

   nRow    := 3 // can be any

   AAdd( aClrs,  aCol := { 1, 1, nClr := GetPixel( hDC, 1, 1 ), cClrToCode( nClr ) } )

   FOR nCol := 2 TO nBmpWidth - 1

      nClr     := GetPixel( hDC, nCol, nRow )

      IF nClr == aCol[ 3 ]

         aCol[ 2 ] := nCol

      ELSE

         aCol  := { nCol, nCol, nClr, cClrToCode( nClr ) }

         AAdd( aClrs, aCol )

      ENDIF

   NEXT nCol

   SelectObject( hDC, hBmpOld )

   Deletedc( hdc )
   ReleaseDC( 0, hDC0 )

RETURN aClrs

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Gradient Colors

Postby nageswaragunupudi » Mon Sep 02, 2024 9:08 pm

Code: Select all  Expand view  RUN
 cTxt := {aClrs}

   MEMOWRIT( cFileTxt, FW_ValToExp( cTxt ) )
 

is not correct:

This is correct:
Code: Select all  Expand view  RUN
MEMOWRIT( cFileTxt, FW_ValToExp( aClrs ) )
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests