 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
dave Guest
|
Posted: Sun Feb 05, 2006 6:01 pm Post subject: Re-combining two bitmaps from delta image |
|
|
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the difference between two other bitmaps. But now I want to 'recombine' the delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm getting problems.
My delta image is mostly black with an area showing the original image, but different colours, where the blue line is. The white text of image B looks brown.
On efg2.com it said the fastest way to combine images for the screen was to blit them. With dwRop set to SrcPaint, the new combined image has the white text, but the thick blue line has some blue in but is mostly white too.
Not sure what I'm missing so any help will be appreciated
Thanks |
|
| Back to top |
|
 |
Mr. X Guest
|
Posted: Mon Feb 06, 2006 1:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
you can experiment with other rops but using scanline to merge both bitmaps
(in 24bit format) is the best way
"dave" <deepthinker (AT) btinternet (DOT) com> wrote in message
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the |
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
| Quote: |
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B |
looks brown.
| Quote: |
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the |
white text, but the thick blue line has some blue in but is mostly white
too.
| Quote: |
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
dave Guest
|
Posted: Mon Feb 06, 2006 3:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
Hi
I experimented with them all and non of them resulted in looking like image B. I thought maybe I needed to do some combination or produce the delta image in a different way.
Im I correct in my understanding that bliting it should be faster as its the graphics card that does the work, freeing up the cpu? I must admit thats not what was appearing to happen in a test app i wrote, the bitblt command seemed to take longer to return from, than the procedure that created the delta image. Admitedly i was only calculating the time it took for a small bitmap.
If I recombine using scanline is it a simple matter of changing the '-' to '+' ?
Thanks for the help
"Mr. X" <no (AT) mail (DOT) here> wrote:
| Quote: | you can experiment with other rops but using scanline to merge both bitmaps
(in 24bit format) is the best way
"dave" <deepthinker (AT) btinternet (DOT) com> wrote in message
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Mon Feb 06, 2006 3:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
Please show your code if you want more help: Maybe for you it's enough clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Mon Feb 06, 2006 6:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
I didn't look too deep in your problem but AFAIU your approuch to the
problem is too simplicistic.
In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0? The pixels
in a bitmap cannot contain negative values and you are using a bitmap as
container for the difference.
You need a different container for the delta values which supports negative
values, for example you could use an array..
Also I don't see the need to use 32bit pixel format, just use 24bit since I
am assuming you are not using alpha channel if you are blitting on a form
canvas.
Hope it helps
Francesco
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e77f90$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi
This is how I'm getting the delta image:
function createDelta(original:TBitMap;new: TBitMap): TBitMap;
var
x,row : Integer;
delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
delta:= TBitMap.create;
delta.TransparentColor:=original.TransparentColor;
delta.TransparentMode:=original.TransparentMode;
delta.Palette:=original.Palette;
original.PixelFormat:=pf32bit;
new.PixelFormat:=pf32bit;
delta.PixelFormat:=pf32bit;
delta.Height:=original.Height;
delta.Width:=original.Width;
for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD := delta.Scanline[y];
for x := 0 to original.Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
result:=delta;
end;
I then try recombining using:
bitblt(form1.Canvas.Handle,x,y,im2.Width,im2.Height,im2.Canvas.Handle,0,0,SrcPaint
)
where im2 is the tbitmap returned from the first function.
thanks
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it
wrote:
Please show your code if you want more help: Maybe for you it's enough
clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
dave Guest
|
Posted: Mon Feb 06, 2006 6:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
Hi
This is how I'm getting the delta image:
function createDelta(original:TBitMap;new: TBitMap): TBitMap;
var
x,row : Integer;
delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
delta:= TBitMap.create;
delta.TransparentColor:=original.TransparentColor;
delta.TransparentMode:=original.TransparentMode;
delta.Palette:=original.Palette;
original.PixelFormat:=pf32bit;
new.PixelFormat:=pf32bit;
delta.PixelFormat:=pf32bit;
delta.Height:=original.Height;
delta.Width:=original.Width;
for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD := delta.Scanline[y];
for x := 0 to original.Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
result:=delta;
end;
I then try recombining using:
bitblt(form1.Canvas.Handle,x,y,im2.Width,im2.Height,im2.Canvas.Handle,0,0,SrcPaint )
where im2 is the tbitmap returned from the first function.
thanks
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it> wrote:
| Quote: | Please show your code if you want more help: Maybe for you it's enough clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
dave Guest
|
Posted: Mon Feb 06, 2006 8:03 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
Hi
Hmm I think you are right, I hadn't thought it through. In a previous post Nils had talked about the delta image being B-A. I have been searching for information on this for a few days with out finding any code examples, or much else.
The idea was to reduce the time involved in transmitting consecutive screengrabs by working out the difference, encode to remove the 0's and transmit it where it could be 'recreated' on the another pc.
So should I/can I use the delta bitmap as a mask to 'remove' the non modified pixels and transmitting that?
Thanks for any help given
D
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it> wrote:
| Quote: | I didn't look too deep in your problem but AFAIU your approuch to the
problem is too simplicistic.
In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0? The pixels
in a bitmap cannot contain negative values and you are using a bitmap as
container for the difference.
You need a different container for the delta values which supports negative
values, for example you could use an array..
Also I don't see the need to use 32bit pixel format, just use 24bit since I
am assuming you are not using alpha channel if you are blitting on a form
canvas.
Hope it helps
Francesco
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e77f90$1 (AT) newsgroups (DOT) borland.com...
Hi
This is how I'm getting the delta image:
function createDelta(original:TBitMap;new: TBitMap): TBitMap;
var
x,row : Integer;
delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
delta:= TBitMap.create;
delta.TransparentColor:=original.TransparentColor;
delta.TransparentMode:=original.TransparentMode;
delta.Palette:=original.Palette;
original.PixelFormat:=pf32bit;
new.PixelFormat:=pf32bit;
delta.PixelFormat:=pf32bit;
delta.Height:=original.Height;
delta.Width:=original.Width;
for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD := delta.Scanline[y];
for x := 0 to original.Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
result:=delta;
end;
I then try recombining using:
bitblt(form1.Canvas.Handle,x,y,im2.Width,im2.Height,im2.Canvas.Handle,0,0,SrcPaint
)
where im2 is the tbitmap returned from the first function.
thanks
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it
wrote:
Please show your code if you want more help: Maybe for you it's enough
clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
Rimvydas Paulavicius Guest
|
Posted: Tue Feb 07, 2006 6:02 am Post subject: Re: Re-combining two bitmaps from delta image |
|
|
You could use xor instead of +- operations.
Rimvydas
Francesco Savastano wrote:
| Quote: | I didn't look too deep in your problem but AFAIU your approuch to the
problem is too simplicistic.
In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0? The pixels
in a bitmap cannot contain negative values and you are using a bitmap as
container for the difference.
You need a different container for the delta values which supports negative
values, for example you could use an array..
Also I don't see the need to use 32bit pixel format, just use 24bit since I
am assuming you are not using alpha channel if you are blitting on a form
canvas.
Hope it helps
Francesco
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e77f90$1 (AT) newsgroups (DOT) borland.com...
Hi
This is how I'm getting the delta image:
function createDelta(original:TBitMap;new: TBitMap): TBitMap;
var
x,row : Integer;
delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
delta:= TBitMap.create;
delta.TransparentColor:=original.TransparentColor;
delta.TransparentMode:=original.TransparentMode;
delta.Palette:=original.Palette;
original.PixelFormat:=pf32bit;
new.PixelFormat:=pf32bit;
delta.PixelFormat:=pf32bit;
delta.Height:=original.Height;
delta.Width:=original.Width;
for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD := delta.Scanline[y];
for x := 0 to original.Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
result:=delta;
end;
I then try recombining using:
bitblt(form1.Canvas.Handle,x,y,im2.Width,im2.Height,im2.Canvas.Handle,0,0,SrcPaint
)
where im2 is the tbitmap returned from the first function.
thanks
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it
wrote:
Please show your code if you want more help: Maybe for you it's enough
clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is the
difference between two other bitmaps. But now I want to 'recombine' the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original image,
but different colours, where the blue line is. The white text of image B
looks brown.
On efg2.com it said the fastest way to combine images for the screen was
to blit them. With dwRop set to SrcPaint, the new combined image has the
white text, but the thick blue line has some blue in but is mostly white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Tue Feb 07, 2006 12:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
I don't know but maybe the solution can be rather simple:
Just check each pixel if it's changed, then put the changed pixel into an
array and transmit them
type
TTransmittedPixel= record
rgb: tcolor;
pos: TPoint;
end;
the recieving computer will then apply the changed pixels on top of other
picture.
--
New World Software
Creative Tools for Creative People
http://new-world-software.com
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e7a444$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi
Hmm I think you are right, I hadn't thought it through. In a previous post
Nils had talked about the delta image being B-A. I have been searching for
information on this for a few days with out finding any code examples, or
much else.
The idea was to reduce the time involved in transmitting consecutive
screengrabs by working out the difference, encode to remove the 0's and
transmit it where it could be 'recreated' on the another pc.
So should I/can I use the delta bitmap as a mask to 'remove' the non
modified pixels and transmitting that?
Thanks for any help given
D
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it
wrote:
I didn't look too deep in your problem but AFAIU your approuch to the
problem is too simplicistic.
In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0? The pixels
in a bitmap cannot contain negative values and you are using a bitmap as
container for the difference.
You need a different container for the delta values which supports
negative
values, for example you could use an array..
Also I don't see the need to use 32bit pixel format, just use 24bit since
I
am assuming you are not using alpha channel if you are blitting on a form
canvas.
Hope it helps
Francesco
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e77f90$1 (AT) newsgroups (DOT) borland.com...
Hi
This is how I'm getting the delta image:
function createDelta(original:TBitMap;new: TBitMap): TBitMap;
var
x,row : Integer;
delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
delta:= TBitMap.create;
delta.TransparentColor:=original.TransparentColor;
delta.TransparentMode:=original.TransparentMode;
delta.Palette:=original.Palette;
original.PixelFormat:=pf32bit;
new.PixelFormat:=pf32bit;
delta.PixelFormat:=pf32bit;
delta.Height:=original.Height;
delta.Width:=original.Width;
for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD := delta.Scanline[y];
for x := 0 to original.Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
result:=delta;
end;
I then try recombining using:
bitblt(form1.Canvas.Handle,x,y,im2.Width,im2.Height,im2.Canvas.Handle,0,0,SrcPaint
)
where im2 is the tbitmap returned from the first function.
thanks
"Francesco Savastano"
francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it
wrote:
Please show your code if you want more help: Maybe for you it's enough
clear
but I was not able to und well what you're trying to do
"dave" <deepthinker (AT) btinternet (DOT) com> ha scritto nel messaggio
news:43e635f7$1 (AT) newsgroups (DOT) borland.com...
Hi
I have bitmap A, which I have 'painted' a thick blue line upon using a
paint program and added some white text, to make bitmap B.
I thought I had worked out how to get the delta bitmap B-A, that is
the
difference between two other bitmaps. But now I want to 'recombine'
the
delta bitmap with the bitmap A onscrean to obtain bitmap B's image I'm
getting problems.
My delta image is mostly black with an area showing the original
image,
but different colours, where the blue line is. The white text of image
B
looks brown.
On efg2.com it said the fastest way to combine images for the screen
was
to blit them. With dwRop set to SrcPaint, the new combined image has
the
white text, but the thick blue line has some blue in but is mostly
white
too.
Not sure what I'm missing so any help will be appreciated
Thanks
|
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Tue Feb 07, 2006 6:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
| Quote: | You could use xor instead of +- operations.
|
While xor also results in 0 if both values are identical, I'd use +-,
because slightly different colors result in small values (127 xor 128 is
255). If you and the result with 255 it should be possible to undo the
operation without problems.
Jens
--
Jens Gruschel
http://www.pegtop.net |
|
| Back to top |
|
 |
Lord Crc Guest
|
Posted: Tue Feb 07, 2006 7:01 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
On Mon, 6 Feb 2006 18:56:08 +0100, "Francesco Savastano"
<francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it> wrote:
| Quote: | In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0?
|
Imagine A = 50, B = 20. Then you get C = -30. However, since C is
stored as a byte, and the processor works in two's complement mode,
this is stored as to 226. When you later perform A + C, the result is
276. This is however larger than 256, and only the lower 8 bits are
stored in the byte B, which results in B = 20.
So you can perfectly well store a difference of two byte's in a byte,
and reconstruct it.
- Asbjørn |
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Tue Feb 07, 2006 11:02 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
anyway it's never good to hit the limits..and where something is too
strangely implemented I highly suspect there are better and easier ways to
do it.
As I already mentioned I don't see why he needs to do the difference of 2
bitmaps: all he needs is to detect if 2 pixel are the same or differ of any
amount and store them into a stream to send to another computer. IMHO If he
creates a 3rd bitmap it is only a waste of memory..
The delta bitmap is as large as the original bitmap so makes no sense to
create it. he just needs to send the minimum amount of informations
necessary to see the changes on another ocmputer.
"Lord Crc" <lordcrc (AT) hotmail (DOT) com> ha scritto nel messaggio
news:bhphu191j5pe655b9f6br27h7u69138ui5 (AT) 4ax (DOT) com...
| Quote: | On Mon, 6 Feb 2006 18:56:08 +0100, "Francesco Savastano"
francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it> wrote:
In a mathematical operation you can do C := B - A and then B := A + C but
did you think about this: what happens if B - A is less than 0?
Imagine A = 50, B = 20. Then you get C = -30. However, since C is
stored as a byte, and the processor works in two's complement mode,
this is stored as to 226. When you later perform A + C, the result is
276. This is however larger than 256, and only the lower 8 bits are
stored in the byte B, which results in B = 20.
So you can perfectly well store a difference of two byte's in a byte,
and reconstruct it.
- Asbjørn |
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Wed Feb 08, 2006 12:04 am Post subject: Re: Re-combining two bitmaps from delta image |
|
|
| Quote: | anyway it's never good to hit the limits..
|
Why not?
| Quote: | As I already mentioned I don't see why he needs to do the difference of 2
bitmaps
|
If he has the difference, he can use a better compression. Well, I don't
know about typical screen images (probably it depends on what
applications you run), but I've done some tests on typical photographs
(years ago). The histogram of the difference bitmap looks like this:
70% 0
10% +-1
5% +-2
2% +-3
1% +-4
....
Doing a huffman or lzw compression to data with such a histogram results
in very good compression rates. And it's independent from the shape of
the changes (a bounding rectangle or tiling probably saves some more
percent).
Well, for high contrast things like text on solid background, probably
xor is as good (or using a completely different approach), because
pixels often change completely. But modern GUIs are using color
gradients or bitmaps with similar colors. If the user moves such a
window slowly, many colors change smoothly, and in this case you get a
histogram like the one above.
Jens
--
Jens Gruschel
http://www.pegtop.net |
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Thu Feb 09, 2006 2:03 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
| Quote: | ok i und your point about the difference bitmap and compression, but i
wonder how much the compression is better or worse than my maybe simple but
straightforward approuch..
|
I haven't tried it, so of course what I said is pure speculation. But I
guess the difference bitmap compresses much better when playing a movie
on the screen or working with Photoshop, while it doesn't when working
with Delphi or Word.
Jens
--
Jens Gruschel
http://www.pegtop.net |
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Thu Feb 09, 2006 2:03 pm Post subject: Re: Re-combining two bitmaps from delta image |
|
|
ok i und your point about the difference bitmap and compression, but i
wonder how much the compression is better or worse than my maybe simple but
straightforward approuch..
--
New World Software
Creative Tools for Creative People
http://new-world-software.com
"Jens Gruschel" <nospam (AT) thisurldoesnotexist (DOT) com> ha scritto nel messaggio
news:43e92378$1 (AT) newsgroups (DOT) borland.com...
| Quote: | anyway it's never good to hit the limits..
Why not?
As I already mentioned I don't see why he needs to do the difference of 2
bitmaps
If he has the difference, he can use a better compression. Well, I don't
know about typical screen images (probably it depends on what applications
you run), but I've done some tests on typical photographs (years ago). The
histogram of the difference bitmap looks like this:
70% 0
10% +-1
5% +-2
2% +-3
1% +-4
...
Doing a huffman or lzw compression to data with such a histogram results
in very good compression rates. And it's independent from the shape of the
changes (a bounding rectangle or tiling probably saves some more percent).
Well, for high contrast things like text on solid background, probably xor
is as good (or using a completely different approach), because pixels
often change completely. But modern GUIs are using color gradients or
bitmaps with similar colors. If the user moves such a window slowly, many
colors change smoothly, and in this case you get a histogram like the one
above.
Jens
--
Jens Gruschel
http://www.pegtop.net |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|