|
|
Home » Developing U++ » UppHub » Raster Control
|
|
Re: Raster Control [message #15110 is a reply to message #15106] |
Tue, 01 April 2008 14:09 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
mrjt wrote on Tue, 01 April 2008 11:22 | I've just run RasterCtrlTest and got the following compilation errors (very easy to fix obviously):
c:\uppsvn\bazaar\rasterctrl\rasterctrl.cpp(79) : error C4716: 'RasterCtrl::Open' : must return a value
c:\uppsvn\bazaar\rasterctrl\rasterctrl.cpp(110) : error C4716: 'RasterCtrl::ShowThumbnails' : must return a value
|
yes, sorry... the error checking was not finished... I'll update svn today.
BTW, I guess we should enable strict warnings on GCC... mine didn't notice the error.
Quote: |
It also seems to crash when loading a single image smaller than the window, as Layout gets called before imageScale is set (I believe).
|
mhhh... I can't reproduce that. Can you tell me how to do it ? I tested with small icons and all seems ok.
Max
[Updated on: Tue, 01 April 2008 14:10] Report message to a moderator
|
|
|
Re: Raster Control [message #15111 is a reply to message #15110] |
Tue, 01 April 2008 15:11 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I'm opening an image that doesn't require thumbnails to be shown and is smaller than the window. This causes 3/4 divide by ZERO errors for various reasons. I appreciate that this is kind of the opposite to how the control is supposed to be used though.
- In RasterThumbsCtrl::CalcScale:
int RasterThumbsCtrl::CalcScale(int imScale, int rasterWidth, int maxPageHeight)
{
// calculates scale factor based on max thumb width
// slightly smaller than ctrl width
int maxScaledWidth = iscale(GetSize().cx, THUMBS_HSIZE_MUL, THUMBS_HSIZE_DIV);
return iscale(maxScaledWidth, 1000, rasterWidth);
} // END RasterThumbsCtrl::CalcScale() With no thumbnails GetSize().cx is 0 since you have previously set the splitter pos to 0. imageScale is then set to 0 and causes a DIVIDE_BY_ZERO. Adding the following after the call to CalcSize in RasterBaseCtrl::Layout
if (!imageScale) {
inside = false;
return;
} fixes it.
- Also RasterBaseCtrl::Layout. You need !0 checks for vScollMax and hScrollMax on the two lines that do:
hScrollBar.Set(iscale(hScrollPos, scaledRasterWidth, hScrollMax)); and the vertical equivalent. I don't really understand what's going on here, but I can't see how this could ever work since vScrollMax should always start as 0.
- RasterBaseCtrl::PaintCache. Add a check for imageScale == 0 at the start of the function.
- ImageCache::Fill, caused when you resize the window down to nothing. Change first line to:
if(imageBuffer.IsEmpty() || !imageBuffer.GetSize().cx || !imageBuffer.GetSize().cy)
Then everything works very nicely .
You also may want to investigate Upp::Scroller. Not sure if this'll help in your case but it's worth a look.
James
[Updated on: Tue, 01 April 2008 18:12] Report message to a moderator
|
|
|
|
|
|
|
Re: Raster Control [message #15125 is a reply to message #15124] |
Tue, 01 April 2008 21:05 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
mrjt wrote on Tue, 01 April 2008 19:08 |
When using MingW __NOASSEMBLY__ is defined, with MSVC it's not....
|
Quite interesting stuff, yes... I think fp math can cope with 0/0 problem, using NANs, maybe.
Well, how can I tell GCC to undefine _NOASSEMBLY_ without patching upp code ?
Max
EDIT : well, I've seen why NOASSEMBLY is defined for GCC... asm syntax is different from MSC to GCC.
IMHO the best way would be to do some alternate assembly code instead of dropping it in GCC....
For example, along with NOASSEMBLY we should define a GCC_ASSEMBLY and MSC_ASSEMBLY and react in consequence.
For now I'll make a small patch on my 'mathutils.cpp' stuff...
Max
[Updated on: Tue, 01 April 2008 21:21] Report message to a moderator
|
|
|
|
Re: Raster Control [message #15127 is a reply to message #15126] |
Tue, 01 April 2008 22:14 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
mr_ped wrote on Tue, 01 April 2008 21:57 | Not only it is divided into C/ASM, but both code paths are different.
The ASM version works purely with integers, while the C version with (double) will lead to decimal division at least, if not multiply (I'm not that big C guru to fully understand how that casting to double will propagate to the rest of calculations).
To get maybe identical version in C you may try:
I'm not sure it will compile absolutely identically, but I think the chances are very good... feel free to compile into ASM firstly and check the result of GCC ASM (-S command line switch?).
|
Well, maybe will be the same, maybe not.
The problem solved by Iscale is rounding working with integers.
To have no precision loss, you should have a temporary integer with twice the integer width, whichever it is... OR use some MULDIV advanced algorithm.
Because of that some assembly language has a built-in muldiv instruction.
The big problem is that in C you've no guarantee of integer sizes, you just know that :
char <= short <= int <= longint <= longlongint
so, you can't know what size to use in intermediate calculation.... because of that in Iscale they use double.
In GCC32 you should have int(32), long(32) and long long(64), so using longlong would be ok.... but I guess that in GCC64 the int is 64 byte wide (maybe), so it won't work either.
BTW, nor the asm code will work without some cheks.
IMHO, the right approach would be to typedef some integer sizes in Core.h :
typedef char int8
typedef short int16
typedef int int32
typedef longlong int64
depending on machine, then use
int32 Iscale(int32 a, int32 b, int32 c)
so it's compiler sake to give needed warnings.
Max
typedef
|
|
|
|
|
Re: Raster Control [message #15204 is a reply to message #15198] |
Wed, 09 April 2008 10:28 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
mr_ped wrote on Tue, 08 April 2008 17:34 | I'm trying it from 2008.1beta2 installation, and I hit crash right after opening first image I found on my disc.
|
well, 2008.1beta2 has an outdated version, anyways... bugs pointed out by mrjt (which caused crash on MSC) are corrected in svn. Please try it, just pick Bazaar from svn, if you don't like to work with upp-svn package.
BTW I stopped upgrading svn packages for the moment cause some lettercase mismatches in uvs2 that brings some problems in linux.
Quote: |
It turned out the very first image I found was gif, and you didn't add plugin/gif package, so the RasterCtrl\RasterCtrl.cpp:55 line
raster = StreamRaster::OpenAny(imageStream);
ends with NULL assigned to raster.
Than the next for loop
for(curPage = 0; curPage < raster->GetPageCount(); curPage++)
will crash due to referencing null pointer.
I think there should be some error handler instead of crash in case the input stream did not result into valid raster object.
|
I agree with you, the package isn't yet refined, in particular to error handling. I'll add some error checks soon.... sorry for the inconvenience but I made the package for a particular need, not yet with production quality in mind
About the gif plugin, I'm not sure if I should add it to RasterControl package or leave it to users if they need it... But that apply to tiff too. IMHO would be better to leave grafic formats out of rastercontrol package and let users include just what they need.
Quote: |
Another funny thing I encountered was opening that gif finally (after I did add plugin/gif package), it fits the width of window (it's scaled up a bit) with vertical scrollbar, than I used View / Zoom 10%, than View / Page width, and I do get both vertical and horizontal scrollbars suddenly. After using View / Page width second time, the horizontal scrollbars is gone and I have the "default" view just like after opening the image.
|
uh ? I didn't notice that behaviour.... it should hide scrollbars when not needed. A known problem is that it can loose the space used by scrollbars (it makes it necessary to calculate the sizes both for control with and without scrollbars to solve it, it's planned but I'm looking for a good (and quick) solution.
But scrollbars hiding should work... can you post a sample image ?
Finally, I'm now working to the hard(ware) part of my fax application, the modem/serial port/threads stuffs, which is quite complicated. When it'll ok, I'll join together with RasterControl so I'll test it much more in depth....
Max
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 07:35:05 CEST 2024
Total time taken to generate the page: 0.12278 seconds
|
|
|