SyntaxBomb - Indie Coders

Languages & Coding => Blitz Code Archives => Graphics => Topic started by: Aurel [banned] on December 25, 2021, 11:10:44

Title: Pixel - Bitmap editor
Post by: Aurel [banned] on December 25, 2021, 11:10:44
hello
it seems to me that most member here LIKE-LOVE Blitz products
That is fine ...
i have a question , Is there any example or snippet how to build
small aka simple pixel editor ..something like sprite editor  or icon editor ?
just for example for 16x16 or 32x32 pixels and that can be saved as .bmp

thanks
Title: Re: Pixel - Bitmap editor
Post by: Pakz on December 25, 2021, 11:21:09
I was working on a simple sprite editor once in blitzplus. I made different version each with a special feature implemented. Sort of tutorial style.

https://github.com/Pakz001/blitzplusexamples

I was watching a screen shots of shoot em up construction kit, and the sprite editor there seems like a minimum style editor that seems like a good reference for minimal sprite editors.
Title: Re: Pixel - Bitmap editor
Post by: Aurel [banned] on December 25, 2021, 11:29:06
thanks
because i don't know...
So i need to download blitz+ first ..right?
I need it in first place like a small pixel editor  not for sprites
but i think that it is same ..
Is Blitzplus free?
Title: Re: Pixel - Bitmap editor
Post by: Aurel [banned] on December 25, 2021, 12:01:08
OK @Pakz
i download Blitz+ from itch.io
and tried your example SpriteEditor 48x48
it is interesting ..it have preview...but don't have some sort of GRID
other examples i must say that i don't understand because i am not familiar with blitz.
thanks again ...i will try some more  ;)
Title: Re: Pixel - Bitmap editor
Post by: Midimaster on December 25, 2021, 18:16:46
I would say a pixel editor can be done with max 50 lines of code.

you only have to read the pixels of a TImage and the draw bigger rectangles at a relative position

In BlitzMax a first step (only black/white) would look like:

Code (BlitzMax) Select
' zoom pixmap
local PixMap:TPixMap=LockImage( MyImage)
For local x:int=0 to 31
    For y:Int= 0 to 31
        If PixMap.ReadPixel(x,y)<>0
            Setcolor 255,255,255
       Else
            Setcolor 255,255,255
       Endif
       DrawRect x*10, y*10, 9 , 9
    Next
Next


Code (BlitzMax) Select
' mouse check and set pixel
local PixMap:TPixMap=LockImage( MyImage)
local mX=MouseX()/10
local mY=MouseY()/10
If PixMap.ReadPixel(x,y)<>0
    PixMap.WritePixel(x,y),0
Else
    PixMap.WritePixel(x,y), $FFFFFFFF
Endif