{{fbdoc item="title" value="IMAGECONVERTROW"}}----
Converts a row of image data into another color depth

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **""ImageConvertRow""** ( [[KeyPgByval|byval]] //src// [[KeyPgAs|as]] [[KeyPgAny|any]]  [[KeyPgPtr|ptr]], [[KeyPgByval|byval]] //src_bpp// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //dst// [[KeyPgAs|as]] [[KeyPgAny|any]]  [[KeyPgPtr|ptr]], [[KeyPgByval|byval]] //dst_bpp// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //width// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //isrgb// [[KeyPgAs|as]] [[KeyPgLong|long]] = 1 )
##
{{fbdoc item="usage"}}##
	**""ImageConvertRow""**( //src//, //src_bpp//, //dst//, //dst_bpp//, //width// [, //isrgb// ] )
##
{{fbdoc item="param"}}
	##//src//##
		The address of the start of the source row.  The source can either be a full-color image with a bit depth of 24 or 32 bits per pixel, or a paletted image with a bit depth of 1-8 bits per pixel.  Converting a paletted image will only work properly if you are in a screen mode that is using the correct palette for the image when you do the conversion.
	##//src_bpp//##
		The number of bits per pixel in the source row.  1-8, 24 and 32.
	##//dst//##
		The address of the start of the destination row.  The image can be a full-color image of 16 or 32 bits per pixel.  If the source is a paletted image, the destination can also be a paletted image of 1 to 8 bits per pixel.
	##//dst_bpp//##
		The number of bits per pixel in the destination row.  Valid values for this are 1-8, 16 and 32.
	##//width//##
		The length of the row in pixels.
	##//isrgb//##
		A value of zero indicates that the Red and Blue channels are the other way round in the source image.  Use this switch if you want the Red and Blue channels to be swapped in the conversion.

{{fbdoc item="desc"}}
	Copies the row of an image from one memory location to another, converting the color information in each pixel to match the destination image.

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/gfx/imageconvertrow.bas"}}%%(freebasic)
#include "fbgfx.bi"
#if __fb_lang__ = "fb"
Using FB
#endif

Const As Long w = 64, h = 64
Dim As IMAGE Ptr img8, img32
Dim As Integer x, y


'' create a 32-bit image, size w*h:
Screenres 1, 1, 32, , GFX_NULL
img32 = ImageCreate(w, h)

If img32 = 0 Then Print "Imagecreate failed on img32!": Sleep: End


'' create an 8-bit image, size w*h:
Screenres 1, 1, 8, , GFX_NULL
img8 = ImageCreate(w, h)

If img8 = 0 Then Print "Imagecreate failed on img8!": Sleep: End


'' fill 8-bit image with a pattern
for y = 0 to h - 1
	for x = 0 to w - 1
		pset img8, (x, y), 56 + (x + y) mod 24
	next x
next y


'' open a graphics window in 8-bit mode, and PUT the image into it:
Screenres 320, 200, 8
Windowtitle "8-bit color mode"
Put (10, 10), img8

Sleep


'' copy the image data into a 32-bit image
Dim As Byte Ptr p8, p32
Dim As Long pitch8, pitch32

#ifndef ImageInfo '' older versions of FB don't have the ImageInfo feature
#define GETPITCH(img_) iif(img_->type=PUT_HEADER_NEW,img_->pitch,img_->old.width*img_->old.bpp)
#define GETP(img_) CPtr(Byte Ptr,img_)+iif(img_->type=PUT_HEADER_NEW,sizeof(PUT_HEADER),sizeof(_OLD_HEADER))
pitch8 = GETPITCH(img8): p8 = GETP(img8)
pitch32 = GETPITCH(img32): p32 = GETP(img32)
#else
ImageInfo( img8,  , , , pitch8,  p8  )
ImageInfo( img32, , , , pitch32, p32 )
#endif

For y = 0 To h - 1
	ImageConvertRow(@p8 [ y * pitch8 ],  8, _
					@p32[ y * pitch32], 32, _
					w)
Next y


'' open a graphics window in 32-bit mode and PUT the image into it:
Screenres 320, 200, 32
Windowtitle "32-bit color mode"
Put (10, 10), img32

Sleep


'' free the images from memory:
ImageDestroy img8
ImageDestroy img32
%%
{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__ImageConvertRow""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgScreenres|ScreenRes]]##
	- ##[[KeyPgGetgraphics|Get (Graphics)]]##
	- ##[[KeyPgPutgraphics|Put (Graphics)]]##
	- ##[[KeyPgImagecreate|ImageCreate]]##
	- ##[[KeyPgImageDestroy|ImageDestroy]]##
	- ##[[KeyPgImageInfo|ImageInfo]]##

{{fbdoc item="back" value="CatPgGfx2D|2D Drawing Functions"}}