Moderators: phlip, Moderators General, Prelates
evilbeanfiend wrote:im confused about why pixels can move, but anyway:
option 1) only allow pixels to be moved via the canvas, pixel is just told were it belongs canvas does the checking
djn wrote:evilbeanfiend wrote:im confused about why pixels can move, but anyway:
option 1) only allow pixels to be moved via the canvas, pixel is just told were it belongs canvas does the checking
Going with this, it might be better (from a memory use perspective, if nothing else) to not store the position in the pixels at all, but instead having a two-dimensional array of pixels in the canvas (where the indexes in the array are the position). You'd need to move some code to the canvas, but that does sort of make sense. Of course, this requires that no two pixels on the same canvas ever have the same position. I'm not sure what you're doing, but it doesn't sound like that should be a problem.
evilbeanfiend wrote:Going with this, it might be better (from a memory use perspective, if nothing else) to not store the position in the pixels at all, but instead having a two-dimensional array of pixels in the canvas (where the indexes in the array are the position). You'd need to move some code to the canvas, but that does sort of make sense. Of course, this requires that no two pixels on the same canvas ever have the same position. I'm not sure what you're doing, but it doesn't sound like that should be a problem.
yes that was my 3rd option, just have an array of data, not everything is an object.
evilbeanfiend wrote:how much data does each pixel have though - if its just the colour then pixels can be an int[][], if you are storing rgb seperately or colour and something else (what it would be i don't know) then yes make a an object (possibly a rbgcolour class rather than pixel?)
Wikipedia wrote:In color text mode, each screen character is actually represented by two bytes. The lower, or character byte is the actual character for the current character set, and the higher, or attribute byte is a bit field used to select various video attributes such as color, blinking, character set, and so forth. This byte-pair scheme is among the features that VGA inherited ultimately from CGA.
evilbeanfiend wrote:ok i still don't get what moving a pixel actually means
evilbeanfiend wrote:you seem to be part way between a bitmap graphics and vector graphics, are you sure you don't want one or the other?
djn wrote:I think it would be clarifying if you renamed them "Cells" instead of "Pixels", since that's essentially what they are.
Dingbats wrote:evilbeanfiend wrote:ok i still don't get what moving a pixel actually means
Uhm... well. When you select a number of pixels (like highlighting in MS Paint, for example), and then move the selection around, it's easier to change the position of the selected pixels than to have the positions static and change what pixels are selected and their colors. I don't know how to explain it so it makes sense, but it does makee sense in my head at least.
evilbeanfiend wrote:you seem to be part way between a bitmap graphics and vector graphics, are you sure you don't want one or the other?
Well, it is a bitmap editor, I think I just confused you with the pixel movement and all.
evilbeanfiend wrote:yes but it sounds like you are representing each pixel in the bitmap as a tiny vector rectangle i.e. i think you are conflating two ideas and not gaining anything from it.
djn wrote:Depends. Since each cell holds a character, think of VGA text modes or ANSI terminals, not bitmaps.

evilbeanfiend wrote:edit: anyway i think u resolved your original dilemma and ive just been slow to pick up on the character part of what you wrote. case closed?
pete wrote:The array idea would still work by the way. Text is normally stored in video memory as 2 bytes per cell/character, starting at b800:0000 (8 bits character, 4 bits background colour, 4 bits foreground). I did something similar in DOS a while back, and copied memory blocks to get non-destructive dragging.
Dingbats wrote:pete wrote:The array idea would still work by the way. Text is normally stored in video memory as 2 bytes per cell/character, starting at b800:0000 (8 bits character, 4 bits background colour, 4 bits foreground). I did something similar in DOS a while back, and copied memory blocks to get non-destructive dragging.
Is that as portable as using an external library though? Not that it matters in this case, because I only do this for learning, but still.
Users browsing this forum: elminster, Farpappestals, Fekeenuisance and 10 guests