Forum Replies Created
- AuthorPosts
Hi depenney, tank you very much for all your support.
Best regardsTank you, now it works!.
Only last litttle problem: when in memory mode i set various values, the resulting image is always 72×72 dpi (openong it from gimp).
Instead in native mode, when i set variuos resolutions, the dpi reflect the resolution i set previously.
Any idea dpenney?
The problem is that i never worked with images….
Best regardsTanks for the reply.
Now i get image not stretched and in BGR format.
Thare’s another problem now: for certains resolutions when i apply a little loop in order to convert from BGR to RGB the scanner produce an image with correct colors; with another resolution no.
The routine is very simple: if i got a buffer (under TWRC_SUCCESS, o the last buffer under TWRX_XFERDONE) i do:
for(int i=0; i{
tmp=buf;
buf=buf[i+2];
buf[i+2]=tmp;
}
where buf is buffer memory.
So i make a little test, and set all bytes to BLUE color, for example.
So i wrote:
for(int i=0; i{
buf = 255;//Its in BGR format, for obtain a BLUE pixel
buf[i+1]=0;
buf[i+2]=0;
}
for all pixels in every buffer.
What i expect is the image is all BLUE, unique color, but it’s not:
I read (edited the image with GIMP) a ilne BLUE, another GREEN and the last RED, for all lines in the image.
It’s strange.
Can u help me about this?
Why i change the resolution this strange behavior?
I make a test with my scanner (BROTHER), the kodaki30 in simulation mode.
Best regardsYes, now its ok, tank you. But theimage (under memory transfer mode)
has some problem: the colors are not interpreted correctly and at certain resolution the image is streched.Now, i can get the image data by a memory transfer, desume the hneeded headers (BITMAPFLILEHEADER and BITMAPINFOHEADER),
and i can save it into the filesystem, but when i open the image with a program (gimp for example) i note that the image is flipped vertically.
Why???
Anyone can say me why the source transfer image data in that way?Post my code in relevants parts:
void doBufferedMemoryTransfer()
{
/*commented code, only explained for semplicity*/
//call DG_CONTROL,DAT_SETUPMEMXFER,MSG_GET so i can setup twMemXFer that is of TW_SETUPMEMXFER type
// call getImageInfo(); and getImageLayout(); that wraps DG_IMAGE,DAT_IMAGEINFO,MSG_GET and DG_IMAGE,DAT_IMAGELAYOUT,MSG_GET respectively
// in a loop i call DG_IMAGE,DAT_IMAGEMEMXFER,MSG_GET until TWRC_XFERDONE is fired by last call to DG_IMAGE,DAT_IMAGEMEMXFER,MSG_GET
/*end commented code*/
...
case TWRC_SUCCESS:
fwrite((void*)buf,1,(UINT)twImageMemXFer.BytesWritten,pFile);
break;
case TWRC_XFERDONE:
//write last buffer into the file
fwrite((void*)buf,1,(UINT)twImageMemXFer.BytesWritten,pFile);
//call fseek to move the file pointer to begin of file in order to write
//image headers that needs to be placed in
fseek ( pFile , 0 , SEEK_SET );
bitmapFileHeader.bfSize = sizeof(BITMAPFILEHEADER) ;
bitmapFileHeader.bfType = 0x4D42;//BM
bitmapFileHeader.bfReserved1 = 0;
bitmapFileHeader.bfReserved2 = 0;
bitmapFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) ;
bitmapInfoHeader.biSize = sizeof(BITMAPINFOHEADER) ;
bitmapInfoHeader.biPlanes = 1;
bitmapInfoHeader.biBitCount = imageInfo->getBitsPerPixel();
bitmapInfoHeader.biCompression = BI_RGB;//imageInfo->getCompression();
bitmapInfoHeader.biSizeImage = ((((imageInfo->getImageWidth() * imageInfo->getBitsPerPixel() + 31) / 32)*4) * abs(imageInfo->getImageLength()));
bitmapInfoHeader.biXPelsPerMeter = 0;
bitmapInfoHeader.biYPelsPerMeter = 0;
bitmapInfoHeader.biClrUsed = 0;
bitmapInfoHeader.biClrImportant = 0;
bitmapInfoHeader.biWidth = imageInfo->getImageWidth();
bitmapInfoHeader.biHeight = imageInfo->getImageLength();
fwrite(&bitmapFileHeader, 1, sizeof(BITMAPFILEHEADER), pFile);
fwrite(&bitmapInfoHeader, 1, sizeof(BITMAPINFOHEADER), pFile);
//other calls to free memory, close file handle and exit from the loop omitted.
break;
}
The imageInfo instance is a instance of a class that wraps TW_IMAGEINFO struct.
best regards
Another question: when i use native mode, the scanner return me a dib handle, so i can desume BITMAPINFOHEADER and BITMAPFILEHEADER structs, save it and then the bitmap bits. it works.
if in my app i want give to end user the choice to save image in another format, i can use any image processing library (imagemagick, freeimage etc.) but only if i save the returned image in bmp format.
So my question: both in memory and native mode (i know that in file mode it is possible), is there any chance to give in other format (jpeg, png, tiff and so on) directly by the device???
In twain spec. is written that in memory mode the device return the image data without header, so the programmer must deduce the headers.
In memory mode, the returned data are always of a bitmap?August 10, 2009 at 12:34 pm in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24988Yeah, i’m now in simulation mode.
I was to read exact instructions.
Tank you Gabe
Best regardsAugust 10, 2009 at 8:58 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24987Hi gabe, i rebooted, but the folder C:WINDOWStwain_32kodakkds_i30_i40 is empty.
No .ds file found nor another.
What can i do?August 10, 2009 at 8:52 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24986Ok, i will just now.
August 10, 2009 at 8:48 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24984gabe, i installed it, but under %windir%twain_32kodak there is nothing.
The kodak folder exists but it does not contain nothing….August 10, 2009 at 8:43 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24983Tank you very much Gabe. Now i will study it.
Best regardsAugust 10, 2009 at 8:05 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24980Kodak i30? what is? and what is simulation mode? it sounds like interesting…
Where can i download it??August 10, 2009 at 7:49 am in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24978I’ve checked just now that document.
I’d read that ICAP_XRESOLUTION (and Y) are dependent from ICAP_BITDEPTH (and when i set ICAP_XRESOLUTION and Y my ICAP_BITDEPTH was 24), wich depends on ICAP_PIXELTYPE (and for my scanner was set to TWPT_RGB), but i send a MSG_SET only for ICAP_XRESOLUTION and ICAP_YRESOLUTION.Best regards
August 7, 2009 at 4:34 pm in reply to: ICAP_XRESOLUTION and ICAP_YRESOLUTION and memory problem #24976Hi Gabe
Units are sets to the TWUN_INCHES value;
What i said is that i got values that display the ui driver of my scanner,
plus some other value (only higher values).
So i perform an aexperiment.
Via my application i set resolution (x and y) to 1200 dpi and this produce
an image (i wrote a simple class DBI.cpp that get DBI handle returned from the scanner and save into the filesystem) about to 300 MB.
So i think that if the ui driver dont display me higher values, is possible that it inquiry my ram and verify if i can set higher dpi, so it hide me higher values.
That other values, not only i get with my app, but with twhacker too, so i’m sure that i’m correct when i inquiry my scanner for that capability.
Do u think?Yeah, it was incorrect: i’m confused in reading the twain doc.
- AuthorPosts