Hi,
Iv never done nothing with images in PB, so maybe my questiosn are to basic.
1.- I want to save one image in the imagegadget as bmp
2.- I want to get every pixel on the imagegadget in a array
3.- Im trying to change the color of a image (my question 2 is about this). The image is black and white and maybe i want to do it green and white or red and white etc.
Its some kind of gradient (in fact is a type of 3d button) and i want to change the colors of the 'gradient'.
I do this same thing a time ago in VB using an array to read every pixel on the image and changing for its equivalent on a different gradient.
Can anybody imagine an easier way?
Thanks in advance:P
2 begginers question about images (want to save as bmp and
I don't know if this is the best way, but that's how I would do it:
Code: Select all
Procedure ChangeGradient(ImageID)
result = 0
GetObject_(ImageID, SizeOf(BITMAP), bm.BITMAP)
bmih.BITMAPINFOHEADER
bmih\biSize = SizeOf(BITMAPINFOHEADER)
bmih\biWidth = bm\bmWidth
bmih\biHeight = bm\bmHeight
bmih\biPlanes = 1
bmih\biBitCount = 32
bmih\biCompression = #BI_RGB
ImageBits = AllocateMemory(0, bm\bmWidth*bmih\biHeight*4)
hDC = GetDC_(WindowID())
If GetDIBits_(hDC, ImageID, 0, bmih\biHeight, ImageBits, bmih, 0)
BMPSeeker = ImageBits
For i=0 To bmih\biHeight-1
For t=0 To bmih\biWidth-1
RGBColour = PeekL(BMPSeeker)
; Do your colour stuff here
; Example: exchange red and green values
RGBColour = ((RGBColour&$FF)<<16)|(RGBColour&$FF00)|((RGBColour&$FF0000)>>16)
;
PokeL(BMPSeeker, RGBColour)
BMPSeeker+4
Next t
Next i
result = SetDIBits_(hDC, ImageID, 0, bmih\biHeight, ImageBits, bmih, 0)
EndIf
ReleaseDC_(WindowID(), hDC)
FreeMemory(0)
ProcedureReturn result
EndProcedure
El_Choni

